Refactor platform calls to File

This commit is contained in:
Ted John committed 2016-12-16 01:25:04 +00:00
1 parent 921c7596df
commit 2c0786eb24
3 files changed
+22 -9

No files matched your search

+15
View File
@@ -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;
+2
View File
@@ -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);
}
+5 -9
View File
@@ -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;