summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/archive_backend.h152
-rw-r--r--src/core/file_sys/archive_romfs.cpp34
-rw-r--r--src/core/file_sys/archive_romfs.h8
-rw-r--r--src/core/file_sys/archive_savedata.cpp2
-rw-r--r--src/core/file_sys/archive_systemsavedata.h2
-rw-r--r--src/core/file_sys/directory_romfs.cpp10
-rw-r--r--src/core/file_sys/disk_archive.cpp10
-rw-r--r--src/core/file_sys/disk_archive.h16
-rw-r--r--src/core/file_sys/file_romfs.cpp32
9 files changed, 97 insertions, 169 deletions
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h
index e2979be17..e153917ea 100644
--- a/src/core/file_sys/archive_backend.h
+++ b/src/core/file_sys/archive_backend.h
@@ -40,40 +40,37 @@ union Mode {
40class Path { 40class Path {
41public: 41public:
42 42
43 Path(): 43 Path() : type(Invalid) {
44 type(Invalid)
45 {
46 } 44 }
47 45
48 Path(const char* path): 46 Path(const char* path) : type(Char), string(path) {
49 type(Char), string(path)
50 {
51 } 47 }
52 48
53 Path(LowPathType type, u32 size, u32 pointer): 49 Path(LowPathType type, u32 size, u32 pointer) : type(type) {
54 type(type)
55 {
56 switch (type) { 50 switch (type) {
57 case Binary: 51 case Binary:
58 { 52 {
59 u8* data = Memory::GetPointer(pointer); 53 u8* data = Memory::GetPointer(pointer);
60 binary = std::vector<u8>(data, data + size); 54 binary = std::vector<u8>(data, data + size);
61 break; 55 break;
62 } 56 }
63 case Char: 57
64 { 58 case Char:
65 const char* data = reinterpret_cast<const char*>(Memory::GetPointer(pointer)); 59 {
66 string = std::string(data, size - 1); // Data is always null-terminated. 60 const char* data = reinterpret_cast<const char*>(Memory::GetPointer(pointer));
67 break; 61 string = std::string(data, size - 1); // Data is always null-terminated.
68 } 62 break;
69 case Wchar: 63 }
70 { 64
71 const char16_t* data = reinterpret_cast<const char16_t*>(Memory::GetPointer(pointer)); 65 case Wchar:
72 u16str = std::u16string(data, size/2 - 1); // Data is always null-terminated. 66 {
73 break; 67 const char16_t* data = reinterpret_cast<const char16_t*>(Memory::GetPointer(pointer));
74 } 68 u16str = std::u16string(data, size/2 - 1); // Data is always null-terminated.
75 default: 69 break;
76 break; 70 }
71
72 default:
73 break;
77 } 74 }
78 } 75 }
79 76
@@ -104,66 +101,64 @@ public:
104 return "[Char: " + AsString() + ']'; 101 return "[Char: " + AsString() + ']';
105 case Wchar: 102 case Wchar:
106 return "[Wchar: " + AsString() + ']'; 103 return "[Wchar: " + AsString() + ']';
107 default:
108 // TODO(yuriks): Add assert
109 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
110 return {};
111 } 104 }
112 } 105 }
113 106
114 const std::string AsString() const { 107 const std::string AsString() const {
115 switch (GetType()) { 108 switch (GetType()) {
116 case Char: 109 case Char:
117 return string; 110 return string;
118 case Wchar: 111 case Wchar:
119 return Common::UTF16ToUTF8(u16str); 112 return Common::UTF16ToUTF8(u16str);
120 case Empty: 113 case Empty:
121 return {}; 114 return {};
122 default: 115 case Invalid:
123 // TODO(yuriks): Add assert 116 case Binary:
124 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!"); 117 // TODO(yuriks): Add assert
125 return {}; 118 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
119 return {};
126 } 120 }
127 } 121 }
128 122
129 const std::u16string AsU16Str() const { 123 const std::u16string AsU16Str() const {
130 switch (GetType()) { 124 switch (GetType()) {
131 case Char: 125 case Char:
132 return Common::UTF8ToUTF16(string); 126 return Common::UTF8ToUTF16(string);
133 case Wchar: 127 case Wchar:
134 return u16str; 128 return u16str;
135 case Empty: 129 case Empty:
136 return {}; 130 return {};
137 default: 131 case Invalid:
138 // TODO(yuriks): Add assert 132 case Binary:
139 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); 133 // TODO(yuriks): Add assert
140 return {}; 134 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!");
135 return {};
141 } 136 }
142 } 137 }
143 138
144 const std::vector<u8> AsBinary() const { 139 const std::vector<u8> AsBinary() const {
145 switch (GetType()) { 140 switch (GetType()) {
146 case Binary: 141 case Binary:
147 return binary; 142 return binary;
148 case Char: 143 case Char:
149 return std::vector<u8>(string.begin(), string.end()); 144 return std::vector<u8>(string.begin(), string.end());
150 case Wchar: 145 case Wchar:
151 { 146 {
152 // use two u8 for each character of u16str 147 // use two u8 for each character of u16str
153 std::vector<u8> to_return(u16str.size() * 2); 148 std::vector<u8> to_return(u16str.size() * 2);
154 for (size_t i = 0; i < u16str.size(); ++i) { 149 for (size_t i = 0; i < u16str.size(); ++i) {
155 u16 tmp_char = u16str.at(i); 150 u16 tmp_char = u16str.at(i);
156 to_return[i*2] = (tmp_char & 0xFF00) >> 8; 151 to_return[i*2] = (tmp_char & 0xFF00) >> 8;
157 to_return[i*2 + 1] = (tmp_char & 0x00FF); 152 to_return[i*2 + 1] = (tmp_char & 0x00FF);
158 }
159 return to_return;
160 } 153 }
161 case Empty: 154 return to_return;
162 return {}; 155 }
163 default: 156 case Empty:
164 // TODO(yuriks): Add assert 157 return {};
165 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!"); 158 case Invalid:
166 return {}; 159 // TODO(yuriks): Add assert
160 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!");
161 return {};
167 } 162 }
168 } 163 }
169 164
@@ -176,7 +171,8 @@ private:
176 171
177class ArchiveBackend : NonCopyable { 172class ArchiveBackend : NonCopyable {
178public: 173public:
179 virtual ~ArchiveBackend() { } 174 virtual ~ArchiveBackend() {
175 }
180 176
181 /** 177 /**
182 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.) 178 * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.)
@@ -196,7 +192,7 @@ public:
196 * @param path Path relative to the archive 192 * @param path Path relative to the archive
197 * @return Whether the file could be deleted 193 * @return Whether the file could be deleted
198 */ 194 */
199 virtual bool DeleteFile(const FileSys::Path& path) const = 0; 195 virtual bool DeleteFile(const Path& path) const = 0;
200 196
201 /** 197 /**
202 * Rename a File specified by its path 198 * Rename a File specified by its path
@@ -204,14 +200,14 @@ public:
204 * @param dest_path Destination path relative to the archive 200 * @param dest_path Destination path relative to the archive
205 * @return Whether rename succeeded 201 * @return Whether rename succeeded
206 */ 202 */
207 virtual bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; 203 virtual bool RenameFile(const Path& src_path, const Path& dest_path) const = 0;
208 204
209 /** 205 /**
210 * Delete a directory specified by its path 206 * Delete a directory specified by its path
211 * @param path Path relative to the archive 207 * @param path Path relative to the archive
212 * @return Whether the directory could be deleted 208 * @return Whether the directory could be deleted
213 */ 209 */
214 virtual bool DeleteDirectory(const FileSys::Path& path) const = 0; 210 virtual bool DeleteDirectory(const Path& path) const = 0;
215 211
216 /** 212 /**
217 * Create a file specified by its path 213 * Create a file specified by its path
@@ -234,7 +230,7 @@ public:
234 * @param dest_path Destination path relative to the archive 230 * @param dest_path Destination path relative to the archive
235 * @return Whether rename succeeded 231 * @return Whether rename succeeded
236 */ 232 */
237 virtual bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const = 0; 233 virtual bool RenameDirectory(const Path& src_path, const Path& dest_path) const = 0;
238 234
239 /** 235 /**
240 * Open a directory specified by its path 236 * Open a directory specified by its path
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index ced0794ef..fdaf73179 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -23,37 +23,21 @@ Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) {
23 } 23 }
24} 24}
25 25
26/**
27 * Open a file specified by its path, using the specified mode
28 * @param path Path relative to the archive
29 * @param mode Mode to open the file with
30 * @return Opened file, or nullptr
31 */
32std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { 26std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const {
33 return Common::make_unique<File_RomFS>(this); 27 return Common::make_unique<File_RomFS>(this);
34} 28}
35 29
36/** 30bool Archive_RomFS::DeleteFile(const Path& path) const {
37 * Delete a file specified by its path
38 * @param path Path relative to the archive
39 * @return Whether the file could be deleted
40 */
41bool Archive_RomFS::DeleteFile(const FileSys::Path& path) const {
42 LOG_WARNING(Service_FS, "Attempted to delete a file from ROMFS."); 31 LOG_WARNING(Service_FS, "Attempted to delete a file from ROMFS.");
43 return false; 32 return false;
44} 33}
45 34
46bool Archive_RomFS::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 35bool Archive_RomFS::RenameFile(const Path& src_path, const Path& dest_path) const {
47 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS."); 36 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
48 return false; 37 return false;
49} 38}
50 39
51/** 40bool Archive_RomFS::DeleteDirectory(const Path& path) const {
52 * Delete a directory specified by its path
53 * @param path Path relative to the archive
54 * @return Whether the directory could be deleted
55 */
56bool Archive_RomFS::DeleteDirectory(const FileSys::Path& path) const {
57 LOG_WARNING(Service_FS, "Attempted to delete a directory from ROMFS."); 41 LOG_WARNING(Service_FS, "Attempted to delete a directory from ROMFS.");
58 return false; 42 return false;
59} 43}
@@ -64,26 +48,16 @@ ResultCode Archive_RomFS::CreateFile(const Path& path, u32 size) const {
64 return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, ErrorLevel::Permanent); 48 return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, ErrorLevel::Permanent);
65} 49}
66 50
67/**
68 * Create a directory specified by its path
69 * @param path Path relative to the archive
70 * @return Whether the directory could be created
71 */
72bool Archive_RomFS::CreateDirectory(const Path& path) const { 51bool Archive_RomFS::CreateDirectory(const Path& path) const {
73 LOG_WARNING(Service_FS, "Attempted to create a directory in ROMFS."); 52 LOG_WARNING(Service_FS, "Attempted to create a directory in ROMFS.");
74 return false; 53 return false;
75} 54}
76 55
77bool Archive_RomFS::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 56bool Archive_RomFS::RenameDirectory(const Path& src_path, const Path& dest_path) const {
78 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS."); 57 LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS.");
79 return false; 58 return false;
80} 59}
81 60
82/**
83 * Open a directory specified by its path
84 * @param path Path relative to the archive
85 * @return Opened directory, or nullptr
86 */
87std::unique_ptr<DirectoryBackend> Archive_RomFS::OpenDirectory(const Path& path) const { 61std::unique_ptr<DirectoryBackend> Archive_RomFS::OpenDirectory(const Path& path) const {
88 return Common::make_unique<Directory_RomFS>(); 62 return Common::make_unique<Directory_RomFS>();
89} 63}
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h
index 2fafd0d2a..5e918f92d 100644
--- a/src/core/file_sys/archive_romfs.h
+++ b/src/core/file_sys/archive_romfs.h
@@ -36,7 +36,7 @@ public:
36 * @param path Path relative to the archive 36 * @param path Path relative to the archive
37 * @return Whether the file could be deleted 37 * @return Whether the file could be deleted
38 */ 38 */
39 bool DeleteFile(const FileSys::Path& path) const override; 39 bool DeleteFile(const Path& path) const override;
40 40
41 /** 41 /**
42 * Rename a File specified by its path 42 * Rename a File specified by its path
@@ -44,14 +44,14 @@ public:
44 * @param dest_path Destination path relative to the archive 44 * @param dest_path Destination path relative to the archive
45 * @return Whether rename succeeded 45 * @return Whether rename succeeded
46 */ 46 */
47 bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; 47 bool RenameFile(const Path& src_path, const Path& dest_path) const override;
48 48
49 /** 49 /**
50 * Delete a directory specified by its path 50 * Delete a directory specified by its path
51 * @param path Path relative to the archive 51 * @param path Path relative to the archive
52 * @return Whether the directory could be deleted 52 * @return Whether the directory could be deleted
53 */ 53 */
54 bool DeleteDirectory(const FileSys::Path& path) const override; 54 bool DeleteDirectory(const Path& path) const override;
55 55
56 /** 56 /**
57 * Create a file specified by its path 57 * Create a file specified by its path
@@ -74,7 +74,7 @@ public:
74 * @param dest_path Destination path relative to the archive 74 * @param dest_path Destination path relative to the archive
75 * @return Whether rename succeeded 75 * @return Whether rename succeeded
76 */ 76 */
77 bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; 77 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
78 78
79 /** 79 /**
80 * Open a directory specified by its path 80 * Open a directory specified by its path
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp
index cb4a80f5b..97853567c 100644
--- a/src/core/file_sys/archive_savedata.cpp
+++ b/src/core/file_sys/archive_savedata.cpp
@@ -16,7 +16,7 @@
16 16
17namespace FileSys { 17namespace FileSys {
18 18
19Archive_SaveData::Archive_SaveData(const std::string& mount_point, u64 program_id) 19Archive_SaveData::Archive_SaveData(const std::string& mount_point, u64 program_id)
20 : DiskArchive(mount_point + Common::StringFromFormat("%016X", program_id) + DIR_SEP) { 20 : DiskArchive(mount_point + Common::StringFromFormat("%016X", program_id) + DIR_SEP) {
21 LOG_INFO(Service_FS, "Directory %s set as SaveData.", this->mount_point.c_str()); 21 LOG_INFO(Service_FS, "Directory %s set as SaveData.", this->mount_point.c_str());
22} 22}
diff --git a/src/core/file_sys/archive_systemsavedata.h b/src/core/file_sys/archive_systemsavedata.h
index 443e27091..55d85193c 100644
--- a/src/core/file_sys/archive_systemsavedata.h
+++ b/src/core/file_sys/archive_systemsavedata.h
@@ -15,7 +15,7 @@
15namespace FileSys { 15namespace FileSys {
16 16
17/// File system interface to the SystemSaveData archive 17/// File system interface to the SystemSaveData archive
18/// TODO(Subv): This archive should point to a location in the NAND, 18/// TODO(Subv): This archive should point to a location in the NAND,
19/// specifically nand:/data/<ID0>/sysdata/<SaveID-Low>/<SaveID-High> 19/// specifically nand:/data/<ID0>/sysdata/<SaveID-Low>/<SaveID-High>
20class Archive_SystemSaveData final : public DiskArchive { 20class Archive_SystemSaveData final : public DiskArchive {
21public: 21public:
diff --git a/src/core/file_sys/directory_romfs.cpp b/src/core/file_sys/directory_romfs.cpp
index 0b95f9b65..e130aca17 100644
--- a/src/core/file_sys/directory_romfs.cpp
+++ b/src/core/file_sys/directory_romfs.cpp
@@ -21,20 +21,10 @@ bool Directory_RomFS::Open() {
21 return false; 21 return false;
22} 22}
23 23
24/**
25 * List files contained in the directory
26 * @param count Number of entries to return at once in entries
27 * @param entries Buffer to read data into
28 * @return Number of entries listed
29 */
30u32 Directory_RomFS::Read(const u32 count, Entry* entries) { 24u32 Directory_RomFS::Read(const u32 count, Entry* entries) {
31 return 0; 25 return 0;
32} 26}
33 27
34/**
35 * Close the directory
36 * @return true if the directory closed correctly
37 */
38bool Directory_RomFS::Close() const { 28bool Directory_RomFS::Close() const {
39 return false; 29 return false;
40} 30}
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index 1689a1a91..0197f727d 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -23,15 +23,15 @@ std::unique_ptr<FileBackend> DiskArchive::OpenFile(const Path& path, const Mode
23 return std::unique_ptr<FileBackend>(file); 23 return std::unique_ptr<FileBackend>(file);
24} 24}
25 25
26bool DiskArchive::DeleteFile(const FileSys::Path& path) const { 26bool DiskArchive::DeleteFile(const Path& path) const {
27 return FileUtil::Delete(GetMountPoint() + path.AsString()); 27 return FileUtil::Delete(GetMountPoint() + path.AsString());
28} 28}
29 29
30bool DiskArchive::RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 30bool DiskArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
31 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 31 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString());
32} 32}
33 33
34bool DiskArchive::DeleteDirectory(const FileSys::Path& path) const { 34bool DiskArchive::DeleteDirectory(const Path& path) const {
35 return FileUtil::DeleteDir(GetMountPoint() + path.AsString()); 35 return FileUtil::DeleteDir(GetMountPoint() + path.AsString());
36} 36}
37 37
@@ -60,7 +60,7 @@ bool DiskArchive::CreateDirectory(const Path& path) const {
60 return FileUtil::CreateDir(GetMountPoint() + path.AsString()); 60 return FileUtil::CreateDir(GetMountPoint() + path.AsString());
61} 61}
62 62
63bool DiskArchive::RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const { 63bool DiskArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const {
64 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString()); 64 return FileUtil::Rename(GetMountPoint() + src_path.AsString(), GetMountPoint() + dest_path.AsString());
65} 65}
66 66
@@ -85,7 +85,7 @@ DiskFile::DiskFile(const DiskArchive* archive, const Path& path, const Mode mode
85 85
86bool DiskFile::Open() { 86bool DiskFile::Open() {
87 if (!mode.create_flag && !FileUtil::Exists(path)) { 87 if (!mode.create_flag && !FileUtil::Exists(path)) {
88 LOG_ERROR(Service_FS, "Non-existing file %s cant be open without mode create.", path.c_str()); 88 LOG_ERROR(Service_FS, "Non-existing file %s can't be open without mode create.", path.c_str());
89 return false; 89 return false;
90 } 90 }
91 91
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h
index 6c9b689e0..018ebd2ed 100644
--- a/src/core/file_sys/disk_archive.h
+++ b/src/core/file_sys/disk_archive.h
@@ -16,8 +16,8 @@
16namespace FileSys { 16namespace FileSys {
17 17
18/** 18/**
19 * Helper which implements a backend accessing the host machine's filesystem. 19 * Helper which implements a backend accessing the host machine's filesystem.
20 * This should be subclassed by concrete archive types, which will provide the 20 * This should be subclassed by concrete archive types, which will provide the
21 * base directory on the host filesystem and override any required functionality. 21 * base directory on the host filesystem and override any required functionality.
22 */ 22 */
23class DiskArchive : public ArchiveBackend { 23class DiskArchive : public ArchiveBackend {
@@ -26,12 +26,12 @@ public:
26 26
27 virtual std::string GetName() const = 0; 27 virtual std::string GetName() const = 0;
28 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override; 28 std::unique_ptr<FileBackend> OpenFile(const Path& path, const Mode mode) const override;
29 bool DeleteFile(const FileSys::Path& path) const override; 29 bool DeleteFile(const Path& path) const override;
30 bool RenameFile(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; 30 bool RenameFile(const Path& src_path, const Path& dest_path) const override;
31 bool DeleteDirectory(const FileSys::Path& path) const override; 31 bool DeleteDirectory(const Path& path) const override;
32 ResultCode CreateFile(const Path& path, u32 size) const override; 32 ResultCode CreateFile(const Path& path, u32 size) const override;
33 bool CreateDirectory(const Path& path) const override; 33 bool CreateDirectory(const Path& path) const override;
34 bool RenameDirectory(const FileSys::Path& src_path, const FileSys::Path& dest_path) const override; 34 bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
35 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; 35 std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override;
36 36
37 /** 37 /**
@@ -50,7 +50,7 @@ class DiskFile : public FileBackend {
50public: 50public:
51 DiskFile(); 51 DiskFile();
52 DiskFile(const DiskArchive* archive, const Path& path, const Mode mode); 52 DiskFile(const DiskArchive* archive, const Path& path, const Mode mode);
53 53
54 ~DiskFile() override { 54 ~DiskFile() override {
55 Close(); 55 Close();
56 } 56 }
@@ -61,7 +61,7 @@ public:
61 size_t GetSize() const override; 61 size_t GetSize() const override;
62 bool SetSize(const u64 size) const override; 62 bool SetSize(const u64 size) const override;
63 bool Close() const override; 63 bool Close() const override;
64 64
65 void Flush() const override { 65 void Flush() const override {
66 file->Flush(); 66 file->Flush();
67 } 67 }
diff --git a/src/core/file_sys/file_romfs.cpp b/src/core/file_sys/file_romfs.cpp
index e79936407..7467d6d31 100644
--- a/src/core/file_sys/file_romfs.cpp
+++ b/src/core/file_sys/file_romfs.cpp
@@ -12,62 +12,30 @@
12 12
13namespace FileSys { 13namespace FileSys {
14 14
15/**
16 * Open the file
17 * @return true if the file opened correctly
18 */
19bool File_RomFS::Open() { 15bool File_RomFS::Open() {
20 return true; 16 return true;
21} 17}
22 18
23/**
24 * Read data from the file
25 * @param offset Offset in bytes to start reading data from
26 * @param length Length in bytes of data to read from file
27 * @param buffer Buffer to read data into
28 * @return Number of bytes read
29 */
30size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const { 19size_t File_RomFS::Read(const u64 offset, const u32 length, u8* buffer) const {
31 LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length); 20 LOG_TRACE(Service_FS, "called offset=%llu, length=%d", offset, length);
32 memcpy(buffer, &archive->raw_data[(u32)offset], length); 21 memcpy(buffer, &archive->raw_data[(u32)offset], length);
33 return length; 22 return length;
34} 23}
35 24
36/**
37 * Write data to the file
38 * @param offset Offset in bytes to start writing data to
39 * @param length Length in bytes of data to write to file
40 * @param flush The flush parameters (0 == do not flush)
41 * @param buffer Buffer to read data from
42 * @return Number of bytes written
43 */
44size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const { 25size_t File_RomFS::Write(const u64 offset, const u32 length, const u32 flush, const u8* buffer) const {
45 LOG_WARNING(Service_FS, "Attempted to write to ROMFS."); 26 LOG_WARNING(Service_FS, "Attempted to write to ROMFS.");
46 return 0; 27 return 0;
47} 28}
48 29
49/**
50 * Get the size of the file in bytes
51 * @return Size of the file in bytes
52 */
53size_t File_RomFS::GetSize() const { 30size_t File_RomFS::GetSize() const {
54 return sizeof(u8) * archive->raw_data.size(); 31 return sizeof(u8) * archive->raw_data.size();
55} 32}
56 33
57/**
58 * Set the size of the file in bytes
59 * @param size New size of the file
60 * @return true if successful
61 */
62bool File_RomFS::SetSize(const u64 size) const { 34bool File_RomFS::SetSize(const u64 size) const {
63 LOG_WARNING(Service_FS, "Attempted to set the size of ROMFS"); 35 LOG_WARNING(Service_FS, "Attempted to set the size of ROMFS");
64 return false; 36 return false;
65} 37}
66 38
67/**
68 * Close the file
69 * @return true if the file closed correctly
70 */
71bool File_RomFS::Close() const { 39bool File_RomFS::Close() const {
72 return false; 40 return false;
73} 41}