filesystem: use std for DeleteFile

Remove custom platform implementation of `DeleteFile` and replace single
use with `std::filesystem::remove` after a negative
`std::filesystem::is_directory` check.
This commit is contained in:
Sandy Carter 2020-04-09 10:27:02 -04:00 committed by Rick Gibbed
parent df65de231f
commit fc5153bca1
4 changed files with 2 additions and 15 deletions

View File

@ -59,10 +59,6 @@ int64_t Tell(FILE* file);
// undefined. // undefined.
bool TruncateStdioFile(FILE* file, uint64_t length); bool TruncateStdioFile(FILE* file, uint64_t length);
// Deletes the file at the given path.
// Returns true if the file was found and removed.
bool DeleteFile(const std::filesystem::path& path);
struct FileAccess { struct FileAccess {
// Implies kFileReadData. // Implies kFileReadData.
static const uint32_t kGenericRead = 0x80000000; static const uint32_t kGenericRead = 0x80000000;

View File

@ -131,11 +131,6 @@ bool CreateFile(const std::filesystem::path& path) {
return false; return false;
} }
bool DeleteFile(const std::filesystem::path& path) {
// TODO: proper implementation.
return (path.c_str()) == 0 ? true : false;
}
class PosixFileHandle : public FileHandle { class PosixFileHandle : public FileHandle {
public: public:
PosixFileHandle(std::filesystem::path path, int handle) PosixFileHandle(std::filesystem::path path, int handle)

View File

@ -13,7 +13,6 @@
#include <string> #include <string>
#undef CreateFile #undef CreateFile
#undef DeleteFile
#include "xenia/base/filesystem.h" #include "xenia/base/filesystem.h"
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
@ -104,10 +103,6 @@ bool TruncateStdioFile(FILE* file, uint64_t length) {
return true; return true;
} }
bool DeleteFile(const std::filesystem::path& path) {
return DeleteFileW(path.c_str()) ? true : false;
}
class Win32FileHandle : public FileHandle { class Win32FileHandle : public FileHandle {
public: public:
Win32FileHandle(const std::filesystem::path& path, HANDLE handle) Win32FileHandle(const std::filesystem::path& path, HANDLE handle)

View File

@ -102,7 +102,8 @@ bool HostPathEntry::DeleteEntryInternal(Entry* entry) {
return std::filesystem::remove_all(full_path); return std::filesystem::remove_all(full_path);
} else { } else {
// Delete file. // Delete file.
return xe::filesystem::DeleteFile(full_path); return !std::filesystem::is_directory(full_path) &&
std::filesystem::remove(full_path);
} }
} }