From 4c06d55a81304d0e658adf441d8bdb90a32ba228 Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 23 Mar 2018 11:09:09 -0500 Subject: [PATCH] FS: Move the file open mode calculation to a separate function. --- src/core/file_sys/disk_filesystem.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 9383bf856b..3a4b45721d 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp @@ -11,13 +11,7 @@ namespace FileSys { -std::string Disk_FileSystem::GetName() const { - return "Disk"; -} - -ResultVal> Disk_FileSystem::OpenFile(const std::string& path, - Mode mode) const { - +static std::string ModeFlagsToString(Mode mode) { std::string mode_str; u32 mode_flags = static_cast(mode); @@ -39,6 +33,19 @@ ResultVal> Disk_FileSystem::OpenFile(const std:: mode_str += "b"; + return mode_str; +} + +std::string Disk_FileSystem::GetName() const { + return "Disk"; +} + +ResultVal> Disk_FileSystem::OpenFile(const std::string& path, + Mode mode) const { + + // Calculate the correct open mode for the file. + std::string mode_str = ModeFlagsToString(mode); + std::string full_path = base_directory + path; auto file = std::make_shared(full_path, mode_str.c_str());