summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-03-20 04:57:34 +0100
committerSubv <subv2112@gmail.com>2018-03-20 04:57:34 +0100
commitfc44261dd1304c7dd1f38999a13ef9734c23b69a (patch)
tree91cbdaae10e1e5b909cab874f9afe8fbbb2d4ed7
parentFS: Implement MountSdCard. (diff)
downloadyuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar.gz
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar.bz2
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar.lz
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar.xz
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.tar.zst
yuzu-fc44261dd1304c7dd1f38999a13ef9734c23b69a.zip
-rw-r--r--src/core/file_sys/disk_filesystem.cpp24
-rw-r--r--src/core/file_sys/filesystem.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index 22b17ba04..9d456e0bf 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -17,10 +17,30 @@ std::string Disk_FileSystem::GetName() const {
ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std::string& path,
Mode mode) const {
- ASSERT_MSG(mode == Mode::Read || mode == Mode::Write, "Other file modes are not supported");
+
+ std::string mode_str = "";
+ u32 mode_flags = static_cast<u32>(mode);
+
+ // Calculate the correct open mode for the file.
+ if ((mode_flags & static_cast<u32>(Mode::Read)) &&
+ (mode_flags & static_cast<u32>(Mode::Write))) {
+ if (mode_flags & static_cast<u32>(Mode::Append))
+ mode_str = "a+";
+ else
+ mode_str = "r+";
+ } else {
+ if (mode_flags & static_cast<u32>(Mode::Read))
+ mode_str = "r";
+ else if (mode_flags & static_cast<u32>(Mode::Append))
+ mode_str = "a";
+ else if (mode_flags & static_cast<u32>(Mode::Write))
+ mode_str = "w";
+ }
+
+ mode_str += "b";
std::string full_path = base_directory + path;
- auto file = std::make_shared<FileUtil::IOFile>(full_path, mode == Mode::Read ? "rb" : "wb");
+ auto file = std::make_shared<FileUtil::IOFile>(full_path, mode_str.c_str());
if (!file->IsOpen()) {
return ERROR_PATH_NOT_FOUND;
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
index 94ad2abf2..4c9993efa 100644
--- a/src/core/file_sys/filesystem.h
+++ b/src/core/file_sys/filesystem.h
@@ -35,6 +35,7 @@ enum EntryType : u32 {
enum class Mode : u32 {
Read = 1,
Write = 2,
+ Append = 4,
};
class Path {