DirectoryBlob: Make PadToAddress and Write32 static

This commit is contained in:
JosJuice 2017-06-10 14:42:41 +02:00
parent ab4762c4c2
commit 953ca9cee1
2 changed files with 23 additions and 25 deletions

View File

@ -39,6 +39,9 @@ static const DiscContent& AddFileToContents(std::set<DiscContent>* contents,
// Returns the number of bytes read.
static size_t ReadFileToVector(const std::string& path, std::vector<u8>* vector);
static void PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer);
static void Write32(u32 data, u32 offset, std::vector<u8>* buffer);
static u32 ComputeNameSize(const File::FSTEntry& parent_entry);
static std::string ASCIIToUppercase(std::string str);
static void ConvertUTF8NamesToSHIFTJIS(File::FSTEntry& parent_entry);
@ -419,27 +422,6 @@ void DirectoryBlobReader::BuildFST(u64 fst_address)
m_virtual_disc.emplace(fst_address, m_fst_data.size(), m_fst_data.data());
}
void DirectoryBlobReader::PadToAddress(u64 start_address, u64* address, u64* length,
u8** buffer) const
{
if (start_address > *address && *length > 0)
{
u64 padBytes = std::min(start_address - *address, *length);
memset(*buffer, 0, (size_t)padBytes);
*length -= padBytes;
*buffer += padBytes;
*address += padBytes;
}
}
void DirectoryBlobReader::Write32(u32 data, u32 offset, std::vector<u8>* const buffer)
{
(*buffer)[offset++] = (data >> 24);
(*buffer)[offset++] = (data >> 16) & 0xff;
(*buffer)[offset++] = (data >> 8) & 0xff;
(*buffer)[offset] = (data)&0xff;
}
void DirectoryBlobReader::WriteEntryData(u32* entry_offset, u8 type, u32 name_offset,
u64 data_offset, u64 length, u32 address_shift)
{
@ -520,6 +502,26 @@ static size_t ReadFileToVector(const std::string& path, std::vector<u8>* vector)
return bytes_read;
}
static void PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer)
{
if (start_address > *address && *length > 0)
{
u64 padBytes = std::min(start_address - *address, *length);
memset(*buffer, 0, (size_t)padBytes);
*length -= padBytes;
*buffer += padBytes;
*address += padBytes;
}
}
static void Write32(u32 data, u32 offset, std::vector<u8>* buffer)
{
(*buffer)[offset++] = (data >> 24);
(*buffer)[offset++] = (data >> 16) & 0xff;
(*buffer)[offset++] = (data >> 8) & 0xff;
(*buffer)[offset] = data & 0xff;
}
static u32 ComputeNameSize(const File::FSTEntry& parent_entry)
{
u32 name_size = 0;

View File

@ -89,10 +89,6 @@ private:
void BuildFST(u64 fst_address);
void PadToAddress(u64 start_address, u64* address, u64* length, u8** buffer) const;
void Write32(u32 data, u32 offset, std::vector<u8>* const buffer);
// FST creation
void WriteEntryData(u32* entry_offset, u8 type, u32 name_offset, u64 data_offset, u64 length,
u32 address_shift);