summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2016-10-20 11:45:01 +0800
committerGravatar wwylele2016-11-19 18:55:34 +0200
commit0647f866498412f22999966cc97b122db2ef9318 (patch)
tree701dc82743f1aae1361d4a0a281416ca354c7ba8 /src
parentFileSys: add SDMCWriteOnlyArchive (diff)
downloadyuzu-0647f866498412f22999966cc97b122db2ef9318.tar.gz
yuzu-0647f866498412f22999966cc97b122db2ef9318.tar.xz
yuzu-0647f866498412f22999966cc97b122db2ef9318.zip
FileSys: w->rw permission lift only happens in SDMC archive
Diffstat (limited to '')
-rw-r--r--src/core/file_sys/archive_sdmc.cpp11
-rw-r--r--src/core/file_sys/archive_sdmc.h1
-rw-r--r--src/core/file_sys/archive_sdmcwriteonly.cpp2
-rw-r--r--src/core/file_sys/disk_archive.cpp2
4 files changed, 14 insertions, 2 deletions
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index c747ba82c..333dfb92e 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -19,6 +19,17 @@ namespace FileSys {
19 19
20ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFile(const Path& path, 20ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFile(const Path& path,
21 const Mode& mode) const { 21 const Mode& mode) const {
22 Mode modified_mode;
23 modified_mode.hex = mode.hex;
24
25 // SDMC archive always opens a file with at least read permission
26 modified_mode.read_flag.Assign(1);
27
28 return OpenFileBase(path, modified_mode);
29}
30
31ResultVal<std::unique_ptr<FileBackend>> SDMCArchive::OpenFileBase(const Path& path,
32 const Mode& mode) const {
22 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex); 33 LOG_DEBUG(Service_FS, "called path=%s mode=%01X", path.DebugStr().c_str(), mode.hex);
23 34
24 const PathParser path_parser(path); 35 const PathParser path_parser(path);
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h
index 4fa47ff35..9d99b110c 100644
--- a/src/core/file_sys/archive_sdmc.h
+++ b/src/core/file_sys/archive_sdmc.h
@@ -36,6 +36,7 @@ public:
36 u64 GetFreeBytes() const override; 36 u64 GetFreeBytes() const override;
37 37
38protected: 38protected:
39 ResultVal<std::unique_ptr<FileBackend>> OpenFileBase(const Path& path, const Mode& mode) const;
39 std::string mount_point; 40 std::string mount_point;
40}; 41};
41 42
diff --git a/src/core/file_sys/archive_sdmcwriteonly.cpp b/src/core/file_sys/archive_sdmcwriteonly.cpp
index 64ae49b86..2aafc9b1d 100644
--- a/src/core/file_sys/archive_sdmcwriteonly.cpp
+++ b/src/core/file_sys/archive_sdmcwriteonly.cpp
@@ -21,7 +21,7 @@ ResultVal<std::unique_ptr<FileBackend>> SDMCWriteOnlyArchive::OpenFile(const Pat
21 LOG_ERROR(Service_FS, "Read flag is not supported"); 21 LOG_ERROR(Service_FS, "Read flag is not supported");
22 return ERROR_INVALID_READ_FLAG; 22 return ERROR_INVALID_READ_FLAG;
23 } 23 }
24 return SDMCArchive::OpenFile(path, mode); 24 return SDMCArchive::OpenFileBase(path, mode);
25} 25}
26 26
27ResultVal<std::unique_ptr<DirectoryBackend>> SDMCWriteOnlyArchive::OpenDirectory( 27ResultVal<std::unique_ptr<DirectoryBackend>> SDMCWriteOnlyArchive::OpenDirectory(
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index 43d199434..0e51fd1a6 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -163,7 +163,7 @@ u64 DiskArchive::GetFreeBytes() const {
163//////////////////////////////////////////////////////////////////////////////////////////////////// 163////////////////////////////////////////////////////////////////////////////////////////////////////
164 164
165ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const { 165ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const {
166 if (!mode.read_flag && !mode.write_flag) 166 if (!mode.read_flag)
167 return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, 167 return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS,
168 ErrorSummary::Canceled, ErrorLevel::Status); 168 ErrorSummary::Canceled, ErrorLevel::Status);
169 169