diff options
| author | 2018-07-27 18:14:03 -0400 | |
|---|---|---|
| committer | 2018-07-27 18:14:03 -0400 | |
| commit | 906d785c73cb3644e8984fbfcbf5fcb8a1ebbc6f (patch) | |
| tree | beff5b868534a8bfb4eea7992553fa5fb5db5287 /src/core/file_sys/vfs.h | |
| parent | Merge pull request #845 from lioncash/nfc (diff) | |
| download | yuzu-906d785c73cb3644e8984fbfcbf5fcb8a1ebbc6f.tar.gz yuzu-906d785c73cb3644e8984fbfcbf5fcb8a1ebbc6f.tar.xz yuzu-906d785c73cb3644e8984fbfcbf5fcb8a1ebbc6f.zip | |
RomFS Extraction
Diffstat (limited to 'src/core/file_sys/vfs.h')
| -rw-r--r-- | src/core/file_sys/vfs.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index 4a13b8378..cf871edd6 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h | |||
| @@ -113,6 +113,9 @@ struct VfsFile : NonCopyable { | |||
| 113 | 113 | ||
| 114 | // Renames the file to name. Returns whether or not the operation was successsful. | 114 | // Renames the file to name. Returns whether or not the operation was successsful. |
| 115 | virtual bool Rename(std::string_view name) = 0; | 115 | virtual bool Rename(std::string_view name) = 0; |
| 116 | |||
| 117 | // Returns the full path of this file as a string, recursively | ||
| 118 | virtual std::string GetFullPath() const; | ||
| 116 | }; | 119 | }; |
| 117 | 120 | ||
| 118 | // A class representing a directory in an abstract filesystem. | 121 | // A class representing a directory in an abstract filesystem. |
| @@ -213,6 +216,17 @@ struct VfsDirectory : NonCopyable { | |||
| 213 | return ReplaceFileWithSubdirectory(file_p, std::make_shared<Directory>(file_p)); | 216 | return ReplaceFileWithSubdirectory(file_p, std::make_shared<Directory>(file_p)); |
| 214 | } | 217 | } |
| 215 | 218 | ||
| 219 | bool InterpretAsDirectory(const std::function<VirtualDir(VirtualFile)>& function, | ||
| 220 | const std::string& file) { | ||
| 221 | auto file_p = GetFile(file); | ||
| 222 | if (file_p == nullptr) | ||
| 223 | return false; | ||
| 224 | return ReplaceFileWithSubdirectory(file_p, function(file_p)); | ||
| 225 | } | ||
| 226 | |||
| 227 | // Returns the full path of this directory as a string, recursively | ||
| 228 | virtual std::string GetFullPath() const; | ||
| 229 | |||
| 216 | protected: | 230 | protected: |
| 217 | // Backend for InterpretAsDirectory. | 231 | // Backend for InterpretAsDirectory. |
| 218 | // Removes all references to file and adds a reference to dir in the directory's implementation. | 232 | // Removes all references to file and adds a reference to dir in the directory's implementation. |
| @@ -230,4 +244,10 @@ struct ReadOnlyVfsDirectory : public VfsDirectory { | |||
| 230 | bool DeleteFile(std::string_view name) override; | 244 | bool DeleteFile(std::string_view name) override; |
| 231 | bool Rename(std::string_view name) override; | 245 | bool Rename(std::string_view name) override; |
| 232 | }; | 246 | }; |
| 247 | |||
| 248 | // A method that copies the raw data between two different implementations of VirtualFile. If you | ||
| 249 | // are using the same implementation, it is probably better to use the Copy method in the parent | ||
| 250 | // directory of src/dest. | ||
| 251 | bool VfsRawCopy(VirtualFile src, VirtualFile dest); | ||
| 252 | |||
| 233 | } // namespace FileSys | 253 | } // namespace FileSys |