diff --git a/src/core/File.cpp b/src/core/File.cpp index 195136cf6d..5e9a7642af 100644 --- a/src/core/File.cpp +++ b/src/core/File.cpp @@ -21,8 +21,23 @@ #include "FileStream.hpp" #include "String.hpp" +extern "C" +{ + #include "../platform/platform.h" +} + namespace File { + bool Copy(const utf8 * srcPath, const utf8 * dstPath, bool overwrite) + { + return platform_file_copy(srcPath, dstPath, overwrite); + } + + bool Delete(const utf8 * path) + { + return platform_file_delete(path); + } + void * ReadAllBytes(const utf8 * path, size_t * length) { void * result = nullptr; diff --git a/src/core/File.h b/src/core/File.h index a911c3fedc..284d9e2adf 100644 --- a/src/core/File.h +++ b/src/core/File.h @@ -20,5 +20,7 @@ namespace File { + bool Copy(const utf8 * srcPath, const utf8 * dstPath, bool overwrite); + bool Delete(const utf8 * path); void * ReadAllBytes(const utf8 * path, size_t * length); } diff --git a/src/title/TitleSequence.cpp b/src/title/TitleSequence.cpp index 7aaddf4db8..1a1f21b2fc 100644 --- a/src/title/TitleSequence.cpp +++ b/src/title/TitleSequence.cpp @@ -31,13 +31,9 @@ #include "../core/Zip.h" #include "TitleSequence.h" -extern "C" -{ - #include "../platform/platform.h" -} - -// defines DeleteFile, which conflicts with IZipArchive call -#undef DeleteFile +#ifndef MAX_PATH + #define MAX_PATH 260 +#endif static std::vector GetSaves(const utf8 * path); static std::vector GetSaves(IZipArchive * zip); @@ -253,7 +249,7 @@ extern "C" utf8 dstPath[MAX_PATH]; String::Set(dstPath, sizeof(dstPath), seq->Path); Path::Append(dstPath, sizeof(dstPath), name); - if (!platform_file_copy(path, dstPath, true)) + if (!File::Copy(path, dstPath, true)) { Console::Error::WriteLine("Unable to copy '%s' to '%s'", path, dstPath); return false; @@ -284,7 +280,7 @@ extern "C" utf8 absolutePath[MAX_PATH]; String::Set(absolutePath, sizeof(absolutePath), seq->Path); Path::Append(absolutePath, sizeof(absolutePath), relativePath); - if (!platform_file_delete(absolutePath)) + if (!File::Delete(absolutePath)) { Console::Error::WriteLine("Unable to delete '%s'", absolutePath); return false;