summaryrefslogtreecommitdiff
path: root/src/core/file_sys/vfs.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-07-27 18:14:03 -0400
committerGravatar Zach Hilman2018-07-27 18:14:03 -0400
commit906d785c73cb3644e8984fbfcbf5fcb8a1ebbc6f (patch)
treebeff5b868534a8bfb4eea7992553fa5fb5db5287 /src/core/file_sys/vfs.cpp
parentMerge pull request #845 from lioncash/nfc (diff)
downloadyuzu-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.cpp23
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
49std::string VfsFile::GetFullPath() const {
50 if (GetContainingDirectory() == nullptr)
51 return "/" + GetName();
52
53 return GetContainingDirectory()->GetFullPath() + "/" + GetName();
54}
55
49std::shared_ptr<VfsFile> VfsDirectory::GetFileRelative(std::string_view path) const { 56std::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
253std::string VfsDirectory::GetFullPath() const {
254 if (IsRoot())
255 return GetName();
256
257 return GetParentDirectory()->GetFullPath() + "/" + GetName();
258}
259
246bool ReadOnlyVfsDirectory::IsWritable() const { 260bool ReadOnlyVfsDirectory::IsWritable() const {
247 return false; 261 return false;
248} 262}
@@ -270,4 +284,13 @@ bool ReadOnlyVfsDirectory::DeleteFile(std::string_view name) {
270bool ReadOnlyVfsDirectory::Rename(std::string_view name) { 284bool ReadOnlyVfsDirectory::Rename(std::string_view name) {
271 return false; 285 return false;
272} 286}
287
288bool 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