diff options
| author | 2018-04-16 06:51:59 -0600 | |
|---|---|---|
| committer | 2018-04-16 06:51:59 -0600 | |
| commit | 83aa38b2390ac4af1757d03d3549d73e26dbfa10 (patch) | |
| tree | eb7db95df6b9fcffa84b426845845e5a0814f2fd /src | |
| parent | file_sys: Add HFS/PFS helper component (diff) | |
| download | yuzu-83aa38b2390ac4af1757d03d3549d73e26dbfa10.tar.gz yuzu-83aa38b2390ac4af1757d03d3549d73e26dbfa10.tar.xz yuzu-83aa38b2390ac4af1757d03d3549d73e26dbfa10.zip | |
file_sys: tweaks
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/partition_filesystem.cpp | 9 | ||||
| -rw-r--r-- | src/core/file_sys/partition_filesystem.h | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index f344e7970..12ba5f315 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cinttypes> | 5 | #include <cinttypes> |
| 6 | #include <utility> | ||
| 6 | #include "common/file_util.h" | 7 | #include "common/file_util.h" |
| 7 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 8 | #include "core/file_sys/partition_filesystem.h" | 9 | #include "core/file_sys/partition_filesystem.h" |
| @@ -44,8 +45,8 @@ Loader::ResultStatus PartitionFilesystem::Load(const std::string& file_path, siz | |||
| 44 | return result; | 45 | return result; |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | Loader::ResultStatus PartitionFilesystem::Load(const std::vector<u8> file_data, size_t offset) { | 48 | Loader::ResultStatus PartitionFilesystem::Load(const std::vector<u8>& file_data, size_t offset) { |
| 48 | size_t total_size = static_cast<size_t>(file_data.size() - offset); | 49 | size_t total_size = file_data.size() - offset; |
| 49 | if (total_size < sizeof(Header)) | 50 | if (total_size < sizeof(Header)) |
| 50 | return Loader::ResultStatus::Error; | 51 | return Loader::ResultStatus::Error; |
| 51 | 52 | ||
| @@ -61,7 +62,7 @@ Loader::ResultStatus PartitionFilesystem::Load(const std::vector<u8> file_data, | |||
| 61 | memcpy(&entry.fs_entry, &file_data[entries_offset + (i * entry_size)], sizeof(FSEntry)); | 62 | memcpy(&entry.fs_entry, &file_data[entries_offset + (i * entry_size)], sizeof(FSEntry)); |
| 62 | entry.name = std::string(reinterpret_cast<const char*>( | 63 | entry.name = std::string(reinterpret_cast<const char*>( |
| 63 | &file_data[strtab_offset + entry.fs_entry.strtab_offset])); | 64 | &file_data[strtab_offset + entry.fs_entry.strtab_offset])); |
| 64 | pfs_entries.push_back(entry); | 65 | pfs_entries.push_back(std::move(entry)); |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | content_offset = strtab_offset + pfs_header.strtab_size; | 68 | content_offset = strtab_offset + pfs_header.strtab_size; |
| @@ -69,7 +70,7 @@ Loader::ResultStatus PartitionFilesystem::Load(const std::vector<u8> file_data, | |||
| 69 | return Loader::ResultStatus::Success; | 70 | return Loader::ResultStatus::Success; |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | u32 PartitionFilesystem::GetNumEntries(void) const { | 73 | u32 PartitionFilesystem::GetNumEntries() const { |
| 73 | return pfs_header.num_entries; | 74 | return pfs_header.num_entries; |
| 74 | } | 75 | } |
| 75 | 76 | ||
diff --git a/src/core/file_sys/partition_filesystem.h b/src/core/file_sys/partition_filesystem.h index 4cc534f50..573c90057 100644 --- a/src/core/file_sys/partition_filesystem.h +++ b/src/core/file_sys/partition_filesystem.h | |||
| @@ -24,9 +24,9 @@ namespace FileSys { | |||
| 24 | class PartitionFilesystem { | 24 | class PartitionFilesystem { |
| 25 | public: | 25 | public: |
| 26 | Loader::ResultStatus Load(const std::string& file_path, size_t offset = 0); | 26 | Loader::ResultStatus Load(const std::string& file_path, size_t offset = 0); |
| 27 | Loader::ResultStatus Load(const std::vector<u8> file_data, size_t offset = 0); | 27 | Loader::ResultStatus Load(const std::vector<u8>& file_data, size_t offset = 0); |
| 28 | 28 | ||
| 29 | u32 GetNumEntries(void) const; | 29 | u32 GetNumEntries() const; |
| 30 | u64 GetEntryOffset(int index) const; | 30 | u64 GetEntryOffset(int index) const; |
| 31 | u64 GetEntrySize(int index) const; | 31 | u64 GetEntrySize(int index) const; |
| 32 | std::string GetEntryName(int index) const; | 32 | std::string GetEntryName(int index) const; |