mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor platform calls to File
This commit is contained in:
parent
921c7596df
commit
2c0786eb24
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -31,13 +31,9 @@
|
|||
#include "../core/Zip.h"
|
||||
#include "TitleSequence.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../platform/platform.h"
|
||||
}
|
||||
|
||||
// <windows.h> defines DeleteFile, which conflicts with IZipArchive call
|
||||
#undef DeleteFile
|
||||
#ifndef MAX_PATH
|
||||
#define MAX_PATH 260
|
||||
#endif
|
||||
|
||||
static std::vector<utf8 *> GetSaves(const utf8 * path);
|
||||
static std::vector<utf8 *> 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;
|
||||
|
|
Loading…
Reference in New Issue