rmdir.cpp 802 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/fs.h>
  5. #include<__vic/windows/wchar.h>
  6. #include<__vic/windows/throw_last_error.h>
  7. #include<windows.h>
  8. namespace __vic {
  9. //----------------------------------------------------------------------------
  10. void rmdir(const char *path)
  11. {
  12. if(!::RemoveDirectoryW(windows::utf8to16(path)))
  13. windows::throw_last_error("RemoveDirectory");
  14. }
  15. //----------------------------------------------------------------------------
  16. bool rmdir_if_exists(const char *path)
  17. {
  18. if(::RemoveDirectoryW(windows::utf8to16(path))) return true; // removed
  19. DWORD err = ::GetLastError();
  20. if(err == ERROR_FILE_NOT_FOUND) return false;
  21. windows::throw_last_error("RemoveDirectory", err);
  22. }
  23. //----------------------------------------------------------------------------
  24. } // namespace