diff --git a/src/file_utils.cc b/src/file_utils.cc index 725eb62..dd48204 100644 --- a/src/file_utils.cc +++ b/src/file_utils.cc @@ -6,8 +6,7 @@ #include #include -#define WIN32_LEAN_AND_MEAN -#include +#include // 0x452740 int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath) @@ -50,7 +49,7 @@ int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath) return -1; } } else { - CopyFileA(existingFilePath, newFilePath, FALSE); + fileCopy(existingFilePath, newFilePath); } return 0; @@ -73,7 +72,7 @@ int fileCopyCompressed(const char* existingFilePath, const char* newFilePath) // Source file is already gzipped, there is no need to do anything // besides copying. fclose(inStream); - CopyFileA(existingFilePath, newFilePath, FALSE); + fileCopy(existingFilePath, newFilePath); } else { gzFile outStream = gzopen(newFilePath, "wb"); if (outStream == NULL) { @@ -136,8 +135,14 @@ int _gzdecompress_file(const char* existingFilePath, const char* newFilePath) gzclose(gzstream); fclose(stream); } else { - CopyFileA(existingFilePath, newFilePath, FALSE); + fileCopy(existingFilePath, newFilePath); } return 0; } + +void fileCopy(const char* existingFilePath, const char* newFilePath) +{ + std::error_code ec; + std::filesystem::copy_file(std::filesystem::path(existingFilePath), std::filesystem::path(newFilePath), ec); +} diff --git a/src/file_utils.h b/src/file_utils.h index 10f626a..fd886f7 100644 --- a/src/file_utils.h +++ b/src/file_utils.h @@ -4,5 +4,6 @@ int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath); int fileCopyCompressed(const char* existingFilePath, const char* newFilePath); int _gzdecompress_file(const char* existingFilePath, const char* newFilePath); +void fileCopy(const char* existingFilePath, const char* newFilePath); #endif /* FILE_UTILS_H */