move_file_if_exists.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/fs.h>
  5. #include<__vic/windows/wchar.h>
  6. #include<windows.h>
  7. namespace __vic {
  8. bool move_file_if_exists_(const wchar_t * , const wchar_t * , DWORD );
  9. //----------------------------------------------------------------------------
  10. bool move_file_if_exists(const wchar_t *src_path, const wchar_t *dest_path)
  11. {
  12. return move_file_if_exists_(src_path, dest_path, MOVEFILE_COPY_ALLOWED);
  13. }
  14. //----------------------------------------------------------------------------
  15. bool move_file_replace_if_exists(
  16. const wchar_t *src_path, const wchar_t *dest_path)
  17. {
  18. return move_file_if_exists_(src_path, dest_path,
  19. MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
  20. }
  21. //----------------------------------------------------------------------------
  22. bool move_file_if_exists(const char *src_path, const char *dest_path)
  23. {
  24. using windows::utf8to16;
  25. return move_file_if_exists(utf8to16(src_path), utf8to16(dest_path));
  26. }
  27. //----------------------------------------------------------------------------
  28. bool move_file_replace_if_exists(
  29. const char *src_path, const char *dest_path)
  30. {
  31. using windows::utf8to16;
  32. return move_file_replace_if_exists(utf8to16(src_path), utf8to16(dest_path));
  33. }
  34. //----------------------------------------------------------------------------
  35. } // namespace