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.cpp | |
| 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.cpp')
| -rw-r--r-- | src/core/file_sys/vfs.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index b99a4fd5b..84a6a7397 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -46,6 +46,13 @@ size_t VfsFile::WriteBytes(const std::vector<u8>& data, size_t offset) { | |||
| 46 | return Write(data.data(), data.size(), offset); | 46 | return Write(data.data(), data.size(), offset); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | std::string VfsFile::GetFullPath() const { | ||
| 50 | if (GetContainingDirectory() == nullptr) | ||
| 51 | return "/" + GetName(); | ||
| 52 | |||
| 53 | return GetContainingDirectory()->GetFullPath() + "/" + GetName(); | ||
| 54 | } | ||
| 55 | |||
| 49 | std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) const { | 56 | std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) const { |
| 50 | auto vec = FileUtil::SplitPathComponents(path); | 57 | auto vec = FileUtil::SplitPathComponents(path); |
| 51 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), | 58 | vec.erase(std::remove_if(vec.begin(), vec.end(), [](const auto& str) { return str.empty(); }), |
| @@ -243,6 +250,13 @@ bool VfsDirectory::Copy(std::string_view src, std::string_view dest) { | |||
| 243 | return f2->WriteBytes(f1->ReadAllBytes()) == f1->GetSize(); | 250 | return f2->WriteBytes(f1->ReadAllBytes()) == f1->GetSize(); |
| 244 | } | 251 | } |
| 245 | 252 | ||
| 253 | std::string VfsDirectory::GetFullPath() const { | ||
| 254 | if (IsRoot()) | ||
| 255 | return GetName(); | ||
| 256 | |||
| 257 | return GetParentDirectory()->GetFullPath() + "/" + GetName(); | ||
| 258 | } | ||
| 259 | |||
| 246 | bool ReadOnlyVfsDirectory::IsWritable() const { | 260 | bool ReadOnlyVfsDirectory::IsWritable() const { |
| 247 | return false; | 261 | return false; |
| 248 | } | 262 | } |
| @@ -270,4 +284,13 @@ bool ReadOnlyVfsDirectory::DeleteFile(std::string_view name) { | |||
| 270 | bool ReadOnlyVfsDirectory::Rename(std::string_view name) { | 284 | bool ReadOnlyVfsDirectory::Rename(std::string_view name) { |
| 271 | return false; | 285 | return false; |
| 272 | } | 286 | } |
| 287 | |||
| 288 | bool VfsRawCopy(VirtualFile src, VirtualFile dest) { | ||
| 289 | if (src == nullptr || dest == nullptr) | ||
| 290 | return false; | ||
| 291 | if (!dest->Resize(src->GetSize())) | ||
| 292 | return false; | ||
| 293 | std::vector<u8> data = src->ReadAllBytes(); | ||
| 294 | return dest->WriteBytes(data, 0) == data.size(); | ||
| 295 | } | ||
| 273 | } // namespace FileSys | 296 | } // namespace FileSys |