WbfsBlob: Don't wrap file_entry in std::unique_ptr

There doesn't seem to be any reason for doing it.
This commit is contained in:
JosJuice 2016-12-31 22:51:16 +01:00
parent 0363be4320
commit b1873264d7
2 changed files with 14 additions and 14 deletions

View File

@ -37,9 +37,9 @@ WbfsFileReader::WbfsFileReader(File::IOFile file, const std::string& path)
// Grab disc info (assume slot 0, checked in ReadHeader()) // Grab disc info (assume slot 0, checked in ReadHeader())
m_wlba_table.resize(m_blocks_per_disc); m_wlba_table.resize(m_blocks_per_disc);
m_files[0]->file.Seek(m_hd_sector_size + WII_DISC_HEADER_SIZE /*+ i * m_disc_info_size*/, m_files[0].file.Seek(m_hd_sector_size + WII_DISC_HEADER_SIZE /*+ i * m_disc_info_size*/,
SEEK_SET); SEEK_SET);
m_files[0]->file.ReadBytes(m_wlba_table.data(), m_blocks_per_disc * sizeof(u16)); m_files[0].file.ReadBytes(m_wlba_table.data(), m_blocks_per_disc * sizeof(u16));
for (size_t i = 0; i < m_blocks_per_disc; i++) for (size_t i = 0; i < m_blocks_per_disc; i++)
m_wlba_table[i] = Common::swap16(m_wlba_table[i]); m_wlba_table[i] = Common::swap16(m_wlba_table[i]);
} }
@ -78,7 +78,7 @@ bool WbfsFileReader::AddFileToList(File::IOFile file)
return false; return false;
const u64 file_size = file.GetSize(); const u64 file_size = file.GetSize();
m_files.emplace_back(std::make_unique<file_entry>(std::move(file), m_size, file_size)); m_files.emplace_back(std::move(file), m_size, file_size);
m_size += file_size; m_size += file_size;
return true; return true;
@ -87,8 +87,8 @@ bool WbfsFileReader::AddFileToList(File::IOFile file)
bool WbfsFileReader::ReadHeader() bool WbfsFileReader::ReadHeader()
{ {
// Read hd size info // Read hd size info
m_files[0]->file.Seek(0, SEEK_SET); m_files[0].file.Seek(0, SEEK_SET);
m_files[0]->file.ReadBytes(&m_header, sizeof(WbfsHeader)); m_files[0].file.ReadBytes(&m_header, sizeof(WbfsHeader));
if (m_header.magic != WBFS_MAGIC) if (m_header.magic != WBFS_MAGIC)
return false; return false;
@ -146,19 +146,19 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
u64 cluster_offset = offset & (m_wbfs_sector_size - 1); u64 cluster_offset = offset & (m_wbfs_sector_size - 1);
u64 final_address = cluster_address + cluster_offset; u64 final_address = cluster_address + cluster_offset;
for (const std::unique_ptr<file_entry>& file_entry : m_files) for (file_entry& file_entry : m_files)
{ {
if (final_address < (file_entry->base_address + file_entry->size)) if (final_address < (file_entry.base_address + file_entry.size))
{ {
file_entry->file.Seek(final_address - file_entry->base_address, SEEK_SET); file_entry.file.Seek(final_address - file_entry.base_address, SEEK_SET);
if (available) if (available)
{ {
u64 till_end_of_file = file_entry->size - (final_address - file_entry->base_address); u64 till_end_of_file = file_entry.size - (final_address - file_entry.base_address);
u64 till_end_of_sector = m_wbfs_sector_size - cluster_offset; u64 till_end_of_sector = m_wbfs_sector_size - cluster_offset;
*available = std::min(till_end_of_file, till_end_of_sector); *available = std::min(till_end_of_file, till_end_of_sector);
} }
return file_entry->file; return file_entry.file;
} }
} }
} }
@ -166,8 +166,8 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
PanicAlert("Read beyond end of disc"); PanicAlert("Read beyond end of disc");
if (available) if (available)
*available = 0; *available = 0;
m_files[0]->file.Seek(0, SEEK_SET); m_files[0].file.Seek(0, SEEK_SET);
return m_files[0]->file; return m_files[0].file;
} }
std::unique_ptr<WbfsFileReader> WbfsFileReader::Create(File::IOFile file, const std::string& path) std::unique_ptr<WbfsFileReader> WbfsFileReader::Create(File::IOFile file, const std::string& path)

View File

@ -53,7 +53,7 @@ private:
u64 size; u64 size;
}; };
std::vector<std::unique_ptr<file_entry>> m_files; std::vector<file_entry> m_files;
u64 m_size; u64 m_size;