summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar David Marcec2018-04-26 14:28:54 -0700
committerGravatar David Marcec2018-04-26 14:28:54 -0700
commit7391741a204d6f25a06132eda214b2199b60a084 (patch)
treeaeeb723744c4563ad608361b82dd938b062a3e09 /src/core/file_sys
parentAdded PREPO to logging backend, Removed comments from SaveReportWithUser (diff)
parentMerge pull request #403 from lioncash/common (diff)
downloadyuzu-7391741a204d6f25a06132eda214b2199b60a084.tar.gz
yuzu-7391741a204d6f25a06132eda214b2199b60a084.tar.xz
yuzu-7391741a204d6f25a06132eda214b2199b60a084.zip
Merge branch 'master' of https://github.com/yuzu-emu/yuzu into service-impl
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/disk_filesystem.cpp33
-rw-r--r--src/core/file_sys/disk_filesystem.h2
-rw-r--r--src/core/file_sys/filesystem.cpp6
-rw-r--r--src/core/file_sys/filesystem.h3
-rw-r--r--src/core/file_sys/partition_filesystem.cpp3
-rw-r--r--src/core/file_sys/program_metadata.cpp39
-rw-r--r--src/core/file_sys/romfs_factory.cpp6
-rw-r--r--src/core/file_sys/romfs_filesystem.cpp41
-rw-r--r--src/core/file_sys/romfs_filesystem.h2
-rw-r--r--src/core/file_sys/savedata_factory.cpp9
-rw-r--r--src/core/file_sys/sdmc_factory.cpp5
11 files changed, 74 insertions, 75 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp
index ca1323873..8aa0e0aa4 100644
--- a/src/core/file_sys/disk_filesystem.cpp
+++ b/src/core/file_sys/disk_filesystem.cpp
@@ -67,26 +67,32 @@ ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const {
67 return RESULT_SUCCESS; 67 return RESULT_SUCCESS;
68} 68}
69 69
70ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 70ResultCode Disk_FileSystem::RenameFile(const std::string& src_path,
71 LOG_WARNING(Service_FS, "(STUBBED) called"); 71 const std::string& dest_path) const {
72 const std::string full_src_path = base_directory + src_path;
73 const std::string full_dest_path = base_directory + dest_path;
74
75 if (!FileUtil::Exists(full_src_path)) {
76 return ERROR_PATH_NOT_FOUND;
77 }
72 // TODO(wwylele): Use correct error code 78 // TODO(wwylele): Use correct error code
73 return ResultCode(-1); 79 return FileUtil::Rename(full_src_path, full_dest_path) ? RESULT_SUCCESS : ResultCode(-1);
74} 80}
75 81
76ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const { 82ResultCode Disk_FileSystem::DeleteDirectory(const Path& path) const {
77 LOG_WARNING(Service_FS, "(STUBBED) called"); 83 NGLOG_WARNING(Service_FS, "(STUBBED) called");
78 // TODO(wwylele): Use correct error code 84 // TODO(wwylele): Use correct error code
79 return ResultCode(-1); 85 return ResultCode(-1);
80} 86}
81 87
82ResultCode Disk_FileSystem::DeleteDirectoryRecursively(const Path& path) const { 88ResultCode Disk_FileSystem::DeleteDirectoryRecursively(const Path& path) const {
83 LOG_WARNING(Service_FS, "(STUBBED) called"); 89 NGLOG_WARNING(Service_FS, "(STUBBED) called");
84 // TODO(wwylele): Use correct error code 90 // TODO(wwylele): Use correct error code
85 return ResultCode(-1); 91 return ResultCode(-1);
86} 92}
87 93
88ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const { 94ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const {
89 LOG_WARNING(Service_FS, "(STUBBED) called"); 95 NGLOG_WARNING(Service_FS, "(STUBBED) called");
90 96
91 std::string full_path = base_directory + path; 97 std::string full_path = base_directory + path;
92 if (size == 0) { 98 if (size == 0) {
@@ -101,7 +107,7 @@ ResultCode Disk_FileSystem::CreateFile(const std::string& path, u64 size) const
101 return RESULT_SUCCESS; 107 return RESULT_SUCCESS;
102 } 108 }
103 109
104 LOG_ERROR(Service_FS, "Too large file"); 110 NGLOG_ERROR(Service_FS, "Too large file");
105 // TODO(Subv): Find out the correct error code 111 // TODO(Subv): Find out the correct error code
106 return ResultCode(-1); 112 return ResultCode(-1);
107} 113}
@@ -114,13 +120,13 @@ ResultCode Disk_FileSystem::CreateDirectory(const std::string& path) const {
114 return RESULT_SUCCESS; 120 return RESULT_SUCCESS;
115 } 121 }
116 122
117 LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", full_path.c_str()); 123 NGLOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating {}", full_path);
118 // TODO(wwylele): Use correct error code 124 // TODO(wwylele): Use correct error code
119 return ResultCode(-1); 125 return ResultCode(-1);
120} 126}
121 127
122ResultCode Disk_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { 128ResultCode Disk_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const {
123 LOG_WARNING(Service_FS, "(STUBBED) called"); 129 NGLOG_WARNING(Service_FS, "(STUBBED) called");
124 // TODO(wwylele): Use correct error code 130 // TODO(wwylele): Use correct error code
125 return ResultCode(-1); 131 return ResultCode(-1);
126} 132}
@@ -140,7 +146,7 @@ ResultVal<std::unique_ptr<DirectoryBackend>> Disk_FileSystem::OpenDirectory(
140} 146}
141 147
142u64 Disk_FileSystem::GetFreeSpaceSize() const { 148u64 Disk_FileSystem::GetFreeSpaceSize() const {
143 LOG_WARNING(Service_FS, "(STUBBED) called"); 149 NGLOG_WARNING(Service_FS, "(STUBBED) called");
144 return 0; 150 return 0;
145} 151}
146 152
@@ -157,14 +163,14 @@ ResultVal<FileSys::EntryType> Disk_FileSystem::GetEntryType(const std::string& p
157} 163}
158 164
159ResultVal<size_t> Disk_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { 165ResultVal<size_t> Disk_Storage::Read(const u64 offset, const size_t length, u8* buffer) const {
160 LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); 166 NGLOG_TRACE(Service_FS, "called offset={}, length={}", offset, length);
161 file->Seek(offset, SEEK_SET); 167 file->Seek(offset, SEEK_SET);
162 return MakeResult<size_t>(file->ReadBytes(buffer, length)); 168 return MakeResult<size_t>(file->ReadBytes(buffer, length));
163} 169}
164 170
165ResultVal<size_t> Disk_Storage::Write(const u64 offset, const size_t length, const bool flush, 171ResultVal<size_t> Disk_Storage::Write(const u64 offset, const size_t length, const bool flush,
166 const u8* buffer) const { 172 const u8* buffer) const {
167 LOG_WARNING(Service_FS, "(STUBBED) called"); 173 NGLOG_WARNING(Service_FS, "(STUBBED) called");
168 file->Seek(offset, SEEK_SET); 174 file->Seek(offset, SEEK_SET);
169 size_t written = file->WriteBytes(buffer, length); 175 size_t written = file->WriteBytes(buffer, length);
170 if (flush) { 176 if (flush) {
@@ -198,8 +204,7 @@ u64 Disk_Directory::Read(const u64 count, Entry* entries) {
198 const std::string& filename = file.virtualName; 204 const std::string& filename = file.virtualName;
199 Entry& entry = entries[entries_read]; 205 Entry& entry = entries[entries_read];
200 206
201 LOG_TRACE(Service_FS, "File %s: size=%llu dir=%d", filename.c_str(), file.size, 207 NGLOG_TRACE(Service_FS, "File {}: size={} dir={}", filename, file.size, file.isDirectory);
202 file.isDirectory);
203 208
204 // TODO(Link Mauve): use a proper conversion to UTF-16. 209 // TODO(Link Mauve): use a proper conversion to UTF-16.
205 for (size_t j = 0; j < FILENAME_LENGTH; ++j) { 210 for (size_t j = 0; j < FILENAME_LENGTH; ++j) {
diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h
index 8f9e1145a..591e39fda 100644
--- a/src/core/file_sys/disk_filesystem.h
+++ b/src/core/file_sys/disk_filesystem.h
@@ -26,7 +26,7 @@ public:
26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 26 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
27 Mode mode) const override; 27 Mode mode) const override;
28 ResultCode DeleteFile(const std::string& path) const override; 28 ResultCode DeleteFile(const std::string& path) const override;
29 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 29 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
30 ResultCode DeleteDirectory(const Path& path) const override; 30 ResultCode DeleteDirectory(const Path& path) const override;
31 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 31 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
32 ResultCode CreateFile(const std::string& path, u64 size) const override; 32 ResultCode CreateFile(const std::string& path, u64 size) const override;
diff --git a/src/core/file_sys/filesystem.cpp b/src/core/file_sys/filesystem.cpp
index 82fdb3c46..87083878b 100644
--- a/src/core/file_sys/filesystem.cpp
+++ b/src/core/file_sys/filesystem.cpp
@@ -71,7 +71,7 @@ std::string Path::AsString() const {
71 case Binary: 71 case Binary:
72 default: 72 default:
73 // TODO(yuriks): Add assert 73 // TODO(yuriks): Add assert
74 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!"); 74 NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
75 return {}; 75 return {};
76 } 76 }
77} 77}
@@ -87,7 +87,7 @@ std::u16string Path::AsU16Str() const {
87 case Invalid: 87 case Invalid:
88 case Binary: 88 case Binary:
89 // TODO(yuriks): Add assert 89 // TODO(yuriks): Add assert
90 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); 90 NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!");
91 return {}; 91 return {};
92 } 92 }
93 93
@@ -115,7 +115,7 @@ std::vector<u8> Path::AsBinary() const {
115 case Invalid: 115 case Invalid:
116 default: 116 default:
117 // TODO(yuriks): Add assert 117 // TODO(yuriks): Add assert
118 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!"); 118 NGLOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!");
119 return {}; 119 return {};
120 } 120 }
121} 121}
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h
index beefcfdb2..295a3133e 100644
--- a/src/core/file_sys/filesystem.h
+++ b/src/core/file_sys/filesystem.h
@@ -126,7 +126,8 @@ public:
126 * @param dest_path Destination path relative to the archive 126 * @param dest_path Destination path relative to the archive
127 * @return Result of the operation 127 * @return Result of the operation
128 */ 128 */
129 virtual ResultCode RenameFile(const Path& src_path, const Path& dest_path) const = 0; 129 virtual ResultCode RenameFile(const std::string& src_path,
130 const std::string& dest_path) const = 0;
130 131
131 /** 132 /**
132 * Rename a Directory specified by its path 133 * Rename a Directory specified by its path
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp
index 4a58a9291..808254ecc 100644
--- a/src/core/file_sys/partition_filesystem.cpp
+++ b/src/core/file_sys/partition_filesystem.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include <utility> 5#include <utility>
7#include "common/file_util.h" 6#include "common/file_util.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
@@ -40,7 +39,7 @@ Loader::ResultStatus PartitionFilesystem::Load(const std::string& file_path, siz
40 39
41 Loader::ResultStatus result = Load(file_data); 40 Loader::ResultStatus result = Load(file_data);
42 if (result != Loader::ResultStatus::Success) 41 if (result != Loader::ResultStatus::Success)
43 LOG_ERROR(Service_FS, "Failed to load PFS from file %s!", file_path.c_str()); 42 NGLOG_ERROR(Service_FS, "Failed to load PFS from file {}!", file_path);
44 43
45 return result; 44 return result;
46} 45}
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp
index a6dcebcc3..1f5ded514 100644
--- a/src/core/file_sys/program_metadata.cpp
+++ b/src/core/file_sys/program_metadata.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include "common/file_util.h" 5#include "common/file_util.h"
7#include "common/logging/log.h" 6#include "common/logging/log.h"
8#include "core/file_sys/program_metadata.h" 7#include "core/file_sys/program_metadata.h"
@@ -22,7 +21,7 @@ Loader::ResultStatus ProgramMetadata::Load(const std::string& file_path) {
22 21
23 Loader::ResultStatus result = Load(file_data); 22 Loader::ResultStatus result = Load(file_data);
24 if (result != Loader::ResultStatus::Success) 23 if (result != Loader::ResultStatus::Success)
25 LOG_ERROR(Service_FS, "Failed to load NPDM from file %s!", file_path.c_str()); 24 NGLOG_ERROR(Service_FS, "Failed to load NPDM from file {}!", file_path);
26 25
27 return result; 26 return result;
28} 27}
@@ -77,14 +76,14 @@ u64 ProgramMetadata::GetFilesystemPermissions() const {
77} 76}
78 77
79void ProgramMetadata::Print() const { 78void ProgramMetadata::Print() const {
80 LOG_DEBUG(Service_FS, "Magic: %.4s", npdm_header.magic.data()); 79 NGLOG_DEBUG(Service_FS, "Magic: {:.4}", npdm_header.magic.data());
81 LOG_DEBUG(Service_FS, "Main thread priority: 0x%02x", npdm_header.main_thread_priority); 80 NGLOG_DEBUG(Service_FS, "Main thread priority: {:#04X}", npdm_header.main_thread_priority);
82 LOG_DEBUG(Service_FS, "Main thread core: %u", npdm_header.main_thread_cpu); 81 NGLOG_DEBUG(Service_FS, "Main thread core: {}", npdm_header.main_thread_cpu);
83 LOG_DEBUG(Service_FS, "Main thread stack size: 0x%x bytes", npdm_header.main_stack_size); 82 NGLOG_DEBUG(Service_FS, "Main thread stack size: {:#X} bytes", npdm_header.main_stack_size);
84 LOG_DEBUG(Service_FS, "Process category: %u", npdm_header.process_category); 83 NGLOG_DEBUG(Service_FS, "Process category: {}", npdm_header.process_category);
85 LOG_DEBUG(Service_FS, "Flags: %02x", npdm_header.flags); 84 NGLOG_DEBUG(Service_FS, "Flags: {:02X}", npdm_header.flags);
86 LOG_DEBUG(Service_FS, " > 64-bit instructions: %s", 85 NGLOG_DEBUG(Service_FS, " > 64-bit instructions: {}",
87 npdm_header.has_64_bit_instructions ? "YES" : "NO"); 86 npdm_header.has_64_bit_instructions ? "YES" : "NO");
88 87
89 auto address_space = "Unknown"; 88 auto address_space = "Unknown";
90 switch (npdm_header.address_space_type) { 89 switch (npdm_header.address_space_type) {
@@ -96,19 +95,19 @@ void ProgramMetadata::Print() const {
96 break; 95 break;
97 } 96 }
98 97
99 LOG_DEBUG(Service_FS, " > Address space: %s\n", address_space); 98 NGLOG_DEBUG(Service_FS, " > Address space: {}\n", address_space);
100 99
101 // Begin ACID printing (potential perms, signed) 100 // Begin ACID printing (potential perms, signed)
102 LOG_DEBUG(Service_FS, "Magic: %.4s", acid_header.magic.data()); 101 NGLOG_DEBUG(Service_FS, "Magic: {:.4}", acid_header.magic.data());
103 LOG_DEBUG(Service_FS, "Flags: %02x", acid_header.flags); 102 NGLOG_DEBUG(Service_FS, "Flags: {:02X}", acid_header.flags);
104 LOG_DEBUG(Service_FS, " > Is Retail: %s", acid_header.is_retail ? "YES" : "NO"); 103 NGLOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO");
105 LOG_DEBUG(Service_FS, "Title ID Min: %016" PRIX64, acid_header.title_id_min); 104 NGLOG_DEBUG(Service_FS, "Title ID Min: {:016X}", acid_header.title_id_min);
106 LOG_DEBUG(Service_FS, "Title ID Max: %016" PRIX64, acid_header.title_id_max); 105 NGLOG_DEBUG(Service_FS, "Title ID Max: {:016X}", acid_header.title_id_max);
107 LOG_DEBUG(Service_FS, "Filesystem Access: %016" PRIX64 "\n", acid_file_access.permissions); 106 NGLOG_DEBUG(Service_FS, "Filesystem Access: {:016X}\n", acid_file_access.permissions);
108 107
109 // Begin ACI0 printing (actual perms, unsigned) 108 // Begin ACI0 printing (actual perms, unsigned)
110 LOG_DEBUG(Service_FS, "Magic: %.4s", aci_header.magic.data()); 109 NGLOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data());
111 LOG_DEBUG(Service_FS, "Title ID: %016" PRIX64, aci_header.title_id); 110 NGLOG_DEBUG(Service_FS, "Title ID: {:016X}", aci_header.title_id);
112 LOG_DEBUG(Service_FS, "Filesystem Access: %016" PRIX64 "\n", aci_file_access.permissions); 111 NGLOG_DEBUG(Service_FS, "Filesystem Access: {:016X}\n", aci_file_access.permissions);
113} 112}
114} // namespace FileSys 113} // namespace FileSys
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp
index b21427948..dc7591aca 100644
--- a/src/core/file_sys/romfs_factory.cpp
+++ b/src/core/file_sys/romfs_factory.cpp
@@ -14,7 +14,7 @@ namespace FileSys {
14RomFS_Factory::RomFS_Factory(Loader::AppLoader& app_loader) { 14RomFS_Factory::RomFS_Factory(Loader::AppLoader& app_loader) {
15 // Load the RomFS from the app 15 // Load the RomFS from the app
16 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) { 16 if (Loader::ResultStatus::Success != app_loader.ReadRomFS(romfs_file, data_offset, data_size)) {
17 LOG_ERROR(Service_FS, "Unable to read RomFS!"); 17 NGLOG_ERROR(Service_FS, "Unable to read RomFS!");
18 } 18 }
19} 19}
20 20
@@ -24,13 +24,13 @@ ResultVal<std::unique_ptr<FileSystemBackend>> RomFS_Factory::Open(const Path& pa
24} 24}
25 25
26ResultCode RomFS_Factory::Format(const Path& path) { 26ResultCode RomFS_Factory::Format(const Path& path) {
27 LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); 27 NGLOG_ERROR(Service_FS, "Unimplemented Format archive {}", GetName());
28 // TODO(bunnei): Find the right error code for this 28 // TODO(bunnei): Find the right error code for this
29 return ResultCode(-1); 29 return ResultCode(-1);
30} 30}
31 31
32ResultVal<ArchiveFormatInfo> RomFS_Factory::GetFormatInfo(const Path& path) const { 32ResultVal<ArchiveFormatInfo> RomFS_Factory::GetFormatInfo(const Path& path) const {
33 LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); 33 NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
34 // TODO(bunnei): Find the right error code for this 34 // TODO(bunnei): Find the right error code for this
35 return ResultCode(-1); 35 return ResultCode(-1);
36} 36}
diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp
index 3d77e2d5f..8e2bce687 100644
--- a/src/core/file_sys/romfs_filesystem.cpp
+++ b/src/core/file_sys/romfs_filesystem.cpp
@@ -21,73 +21,72 @@ ResultVal<std::unique_ptr<StorageBackend>> RomFS_FileSystem::OpenFile(const std:
21} 21}
22 22
23ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const { 23ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const {
24 LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).", 24 NGLOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive ({}).", GetName());
25 GetName().c_str());
26 // TODO(bunnei): Use correct error code 25 // TODO(bunnei): Use correct error code
27 return ResultCode(-1); 26 return ResultCode(-1);
28} 27}
29 28
30ResultCode RomFS_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { 29ResultCode RomFS_FileSystem::RenameFile(const std::string& src_path,
31 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", 30 const std::string& dest_path) const {
32 GetName().c_str()); 31 NGLOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).",
32 GetName());
33 // TODO(wwylele): Use correct error code 33 // TODO(wwylele): Use correct error code
34 return ResultCode(-1); 34 return ResultCode(-1);
35} 35}
36 36
37ResultCode RomFS_FileSystem::DeleteDirectory(const Path& path) const { 37ResultCode RomFS_FileSystem::DeleteDirectory(const Path& path) const {
38 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).", 38 NGLOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).",
39 GetName().c_str()); 39 GetName());
40 // TODO(wwylele): Use correct error code 40 // TODO(wwylele): Use correct error code
41 return ResultCode(-1); 41 return ResultCode(-1);
42} 42}
43 43
44ResultCode RomFS_FileSystem::DeleteDirectoryRecursively(const Path& path) const { 44ResultCode RomFS_FileSystem::DeleteDirectoryRecursively(const Path& path) const {
45 LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive (%s).", 45 NGLOG_CRITICAL(Service_FS, "Attempted to delete a directory from an ROMFS archive ({}).",
46 GetName().c_str()); 46 GetName());
47 // TODO(wwylele): Use correct error code 47 // TODO(wwylele): Use correct error code
48 return ResultCode(-1); 48 return ResultCode(-1);
49} 49}
50 50
51ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const { 51ResultCode RomFS_FileSystem::CreateFile(const std::string& path, u64 size) const {
52 LOG_CRITICAL(Service_FS, "Attempted to create a file in an ROMFS archive (%s).", 52 NGLOG_CRITICAL(Service_FS, "Attempted to create a file in an ROMFS archive ({}).", GetName());
53 GetName().c_str());
54 // TODO(bunnei): Use correct error code 53 // TODO(bunnei): Use correct error code
55 return ResultCode(-1); 54 return ResultCode(-1);
56} 55}
57 56
58ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const { 57ResultCode RomFS_FileSystem::CreateDirectory(const std::string& path) const {
59 LOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive (%s).", 58 NGLOG_CRITICAL(Service_FS, "Attempted to create a directory in an ROMFS archive ({}).",
60 GetName().c_str()); 59 GetName());
61 // TODO(wwylele): Use correct error code 60 // TODO(wwylele): Use correct error code
62 return ResultCode(-1); 61 return ResultCode(-1);
63} 62}
64 63
65ResultCode RomFS_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const { 64ResultCode RomFS_FileSystem::RenameDirectory(const Path& src_path, const Path& dest_path) const {
66 LOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive (%s).", 65 NGLOG_CRITICAL(Service_FS, "Attempted to rename a file within an ROMFS archive ({}).",
67 GetName().c_str()); 66 GetName());
68 // TODO(wwylele): Use correct error code 67 // TODO(wwylele): Use correct error code
69 return ResultCode(-1); 68 return ResultCode(-1);
70} 69}
71 70
72ResultVal<std::unique_ptr<DirectoryBackend>> RomFS_FileSystem::OpenDirectory( 71ResultVal<std::unique_ptr<DirectoryBackend>> RomFS_FileSystem::OpenDirectory(
73 const std::string& path) const { 72 const std::string& path) const {
74 LOG_WARNING(Service_FS, "Opening Directory in a ROMFS archive"); 73 NGLOG_WARNING(Service_FS, "Opening Directory in a ROMFS archive");
75 return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<ROMFSDirectory>()); 74 return MakeResult<std::unique_ptr<DirectoryBackend>>(std::make_unique<ROMFSDirectory>());
76} 75}
77 76
78u64 RomFS_FileSystem::GetFreeSpaceSize() const { 77u64 RomFS_FileSystem::GetFreeSpaceSize() const {
79 LOG_WARNING(Service_FS, "Attempted to get the free space in an ROMFS archive"); 78 NGLOG_WARNING(Service_FS, "Attempted to get the free space in an ROMFS archive");
80 return 0; 79 return 0;
81} 80}
82 81
83ResultVal<FileSys::EntryType> RomFS_FileSystem::GetEntryType(const std::string& path) const { 82ResultVal<FileSys::EntryType> RomFS_FileSystem::GetEntryType(const std::string& path) const {
84 LOG_CRITICAL(Service_FS, "Called within an ROMFS archive (path %s).", path.c_str()); 83 NGLOG_CRITICAL(Service_FS, "Called within an ROMFS archive (path {}).", path);
85 // TODO(wwylele): Use correct error code 84 // TODO(wwylele): Use correct error code
86 return ResultCode(-1); 85 return ResultCode(-1);
87} 86}
88 87
89ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8* buffer) const { 88ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8* buffer) const {
90 LOG_TRACE(Service_FS, "called offset=%llu, length=%zu", offset, length); 89 NGLOG_TRACE(Service_FS, "called offset={}, length={}", offset, length);
91 romfs_file->Seek(data_offset + offset, SEEK_SET); 90 romfs_file->Seek(data_offset + offset, SEEK_SET);
92 size_t read_length = (size_t)std::min((u64)length, data_size - offset); 91 size_t read_length = (size_t)std::min((u64)length, data_size - offset);
93 92
@@ -96,7 +95,7 @@ ResultVal<size_t> RomFS_Storage::Read(const u64 offset, const size_t length, u8*
96 95
97ResultVal<size_t> RomFS_Storage::Write(const u64 offset, const size_t length, const bool flush, 96ResultVal<size_t> RomFS_Storage::Write(const u64 offset, const size_t length, const bool flush,
98 const u8* buffer) const { 97 const u8* buffer) const {
99 LOG_ERROR(Service_FS, "Attempted to write to ROMFS file"); 98 NGLOG_ERROR(Service_FS, "Attempted to write to ROMFS file");
100 // TODO(Subv): Find error code 99 // TODO(Subv): Find error code
101 return MakeResult<size_t>(0); 100 return MakeResult<size_t>(0);
102} 101}
@@ -106,7 +105,7 @@ u64 RomFS_Storage::GetSize() const {
106} 105}
107 106
108bool RomFS_Storage::SetSize(const u64 size) const { 107bool RomFS_Storage::SetSize(const u64 size) const {
109 LOG_ERROR(Service_FS, "Attempted to set the size of an ROMFS file"); 108 NGLOG_ERROR(Service_FS, "Attempted to set the size of an ROMFS file");
110 return false; 109 return false;
111} 110}
112 111
diff --git a/src/core/file_sys/romfs_filesystem.h b/src/core/file_sys/romfs_filesystem.h
index 1b5cac409..ba9d85823 100644
--- a/src/core/file_sys/romfs_filesystem.h
+++ b/src/core/file_sys/romfs_filesystem.h
@@ -32,7 +32,7 @@ public:
32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, 32 ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path,
33 Mode mode) const override; 33 Mode mode) const override;
34 ResultCode DeleteFile(const std::string& path) const override; 34 ResultCode DeleteFile(const std::string& path) const override;
35 ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; 35 ResultCode RenameFile(const std::string& src_path, const std::string& dest_path) const override;
36 ResultCode DeleteDirectory(const Path& path) const override; 36 ResultCode DeleteDirectory(const Path& path) const override;
37 ResultCode DeleteDirectoryRecursively(const Path& path) const override; 37 ResultCode DeleteDirectoryRecursively(const Path& path) const override;
38 ResultCode CreateFile(const std::string& path, u64 size) const override; 38 ResultCode CreateFile(const std::string& path, u64 size) const override;
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index 14868fed2..c1be8fee4 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -2,11 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include <memory> 5#include <memory>
7#include "common/common_types.h" 6#include "common/common_types.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
9#include "common/string_util.h"
10#include "core/core.h" 8#include "core/core.h"
11#include "core/file_sys/disk_filesystem.h" 9#include "core/file_sys/disk_filesystem.h"
12#include "core/file_sys/savedata_factory.h" 10#include "core/file_sys/savedata_factory.h"
@@ -30,7 +28,7 @@ ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path&
30} 28}
31 29
32ResultCode SaveData_Factory::Format(const Path& path) { 30ResultCode SaveData_Factory::Format(const Path& path) {
33 LOG_WARNING(Service_FS, "Format archive %s", GetName().c_str()); 31 NGLOG_WARNING(Service_FS, "Format archive {}", GetName());
34 // Create the save data directory. 32 // Create the save data directory.
35 if (!FileUtil::CreateFullPath(GetFullPath())) { 33 if (!FileUtil::CreateFullPath(GetFullPath())) {
36 // TODO(Subv): Find the correct error code. 34 // TODO(Subv): Find the correct error code.
@@ -41,7 +39,7 @@ ResultCode SaveData_Factory::Format(const Path& path) {
41} 39}
42 40
43ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const { 41ResultVal<ArchiveFormatInfo> SaveData_Factory::GetFormatInfo(const Path& path) const {
44 LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); 42 NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
45 // TODO(bunnei): Find the right error code for this 43 // TODO(bunnei): Find the right error code for this
46 return ResultCode(-1); 44 return ResultCode(-1);
47} 45}
@@ -50,8 +48,7 @@ std::string SaveData_Factory::GetFullPath() const {
50 u64 title_id = Core::CurrentProcess()->program_id; 48 u64 title_id = Core::CurrentProcess()->program_id;
51 // TODO(Subv): Somehow obtain this value. 49 // TODO(Subv): Somehow obtain this value.
52 u32 user = 0; 50 u32 user = 0;
53 return Common::StringFromFormat("%ssave/%016" PRIX64 "/%08X/", nand_directory.c_str(), title_id, 51 return fmt::format("{}save/{:016X}/{:08X}/", nand_directory, title_id, user);
54 user);
55} 52}
56 53
57} // namespace FileSys 54} // namespace FileSys
diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp
index 00e80d2a7..59ac3e0be 100644
--- a/src/core/file_sys/sdmc_factory.cpp
+++ b/src/core/file_sys/sdmc_factory.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cinttypes>
6#include <memory> 5#include <memory>
7#include "common/common_types.h" 6#include "common/common_types.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
@@ -26,13 +25,13 @@ ResultVal<std::unique_ptr<FileSystemBackend>> SDMC_Factory::Open(const Path& pat
26} 25}
27 26
28ResultCode SDMC_Factory::Format(const Path& path) { 27ResultCode SDMC_Factory::Format(const Path& path) {
29 LOG_ERROR(Service_FS, "Unimplemented Format archive %s", GetName().c_str()); 28 NGLOG_ERROR(Service_FS, "Unimplemented Format archive {}", GetName());
30 // TODO(Subv): Find the right error code for this 29 // TODO(Subv): Find the right error code for this
31 return ResultCode(-1); 30 return ResultCode(-1);
32} 31}
33 32
34ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const { 33ResultVal<ArchiveFormatInfo> SDMC_Factory::GetFormatInfo(const Path& path) const {
35 LOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive %s", GetName().c_str()); 34 NGLOG_ERROR(Service_FS, "Unimplemented GetFormatInfo archive {}", GetName());
36 // TODO(bunnei): Find the right error code for this 35 // TODO(bunnei): Find the right error code for this
37 return ResultCode(-1); 36 return ResultCode(-1);
38} 37}