diff options
| author | JosJuice <josjuice@gmail.com> | 2017-06-10 13:02:16 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2017-08-01 11:36:40 +0200 |
| commit | 0d4ad0e39e633d911cced0ecb13b90d873c78271 (patch) | |
| tree | c5ff953f1dd159cd11d9202846933f9d3589b505 /Source/Core/DiscIO/DirectoryBlob.cpp | |
| parent | ef39b4da4611169bab695d3943df794430cd7c45 (diff) | |
DirectoryBlob: Remove m_fst_name_offset
Diffstat (limited to 'Source/Core/DiscIO/DirectoryBlob.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DirectoryBlob.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 004cc46a82..be540b30ef 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -386,8 +386,8 @@ void DirectoryBlobReader::BuildFST(u64 fst_address) u32 name_table_size = Common::AlignUp(ComputeNameSize(rootEntry), 1ull << m_address_shift); u64 total_entries = rootEntry.size + 1; // The root entry itself isn't counted in rootEntry.size - m_fst_name_offset = total_entries * ENTRY_SIZE; // offset of name table in FST - m_fst_data.resize(m_fst_name_offset + name_table_size); + const u64 name_table_offset = total_entries * ENTRY_SIZE; + m_fst_data.resize(name_table_offset + name_table_size); // 32 KiB aligned start of data on disk u64 current_data_address = Common::AlignUp(fst_address + m_fst_data.size(), 0x8000ull); @@ -399,7 +399,8 @@ void DirectoryBlobReader::BuildFST(u64 fst_address) // write root entry WriteEntryData(&fst_offset, DIRECTORY_ENTRY, 0, 0, total_entries, m_address_shift); - WriteDirectory(rootEntry, &fst_offset, &name_offset, ¤t_data_address, root_offset); + WriteDirectory(rootEntry, &fst_offset, &name_offset, ¤t_data_address, root_offset, + name_table_offset); // overflow check, compare the aligned name offset with the aligned name table size _assert_(Common::AlignUp(name_offset, 1ull << m_address_shift) == name_table_size); @@ -449,15 +450,17 @@ void DirectoryBlobReader::WriteEntryData(u32* entry_offset, u8 type, u32 name_of *entry_offset += 4; } -void DirectoryBlobReader::WriteEntryName(u32* name_offset, const std::string& name) +void DirectoryBlobReader::WriteEntryName(u32* name_offset, const std::string& name, + u64 name_table_offset) { - strncpy((char*)&m_fst_data[*name_offset + m_fst_name_offset], name.c_str(), name.length() + 1); + strncpy((char*)&m_fst_data[*name_offset + name_table_offset], name.c_str(), name.length() + 1); *name_offset += (u32)(name.length() + 1); } void DirectoryBlobReader::WriteDirectory(const File::FSTEntry& parent_entry, u32* fst_offset, - u32* name_offset, u64* data_offset, u32 parent_entry_index) + u32* name_offset, u64* data_offset, u32 parent_entry_index, + u64 name_table_offset) { std::vector<File::FSTEntry> sorted_entries = parent_entry.children; @@ -476,16 +479,16 @@ void DirectoryBlobReader::WriteDirectory(const File::FSTEntry& parent_entry, u32 u32 entry_index = *fst_offset / ENTRY_SIZE; WriteEntryData(fst_offset, DIRECTORY_ENTRY, *name_offset, parent_entry_index, entry_index + entry.size + 1, 0); - WriteEntryName(name_offset, entry.virtualName); + WriteEntryName(name_offset, entry.virtualName, name_table_offset); - WriteDirectory(entry, fst_offset, name_offset, data_offset, entry_index); + WriteDirectory(entry, fst_offset, name_offset, data_offset, entry_index, name_table_offset); } else { // put entry in FST WriteEntryData(fst_offset, FILE_ENTRY, *name_offset, *data_offset, entry.size, m_address_shift); - WriteEntryName(name_offset, entry.virtualName); + WriteEntryName(name_offset, entry.virtualName, name_table_offset); // write entry to virtual disc auto result = m_virtual_disc.emplace(*data_offset, entry.size, entry.physicalName); |
