rmdir.cpp 672 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/fs.h>
  5. #include<__vic/posix/error.h>
  6. #include<__vic/throw_errno.h>
  7. #include<unistd.h>
  8. #include<cerrno>
  9. namespace __vic {
  10. //----------------------------------------------------------------------------
  11. void rmdir(const char *path)
  12. {
  13. if(::rmdir(path)) throw_errno("rmdir");
  14. }
  15. //----------------------------------------------------------------------------
  16. bool rmdir_if_exists(const char *path)
  17. {
  18. if(::rmdir(path) == 0) return true; // removed
  19. int err = errno;
  20. if(posix::is_ENOENT(err)) return false;
  21. throw_errno("rmdir", err);
  22. }
  23. //----------------------------------------------------------------------------
  24. } // namespace