Skip to content

Commit

Permalink
WbfsBlob: Remove m_total_files
Browse files Browse the repository at this point in the history
std::vector already keeps track of this for us.
  • Loading branch information
JosJuice committed Dec 21, 2016
1 parent b314333 commit 9459497
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 9 additions & 8 deletions Source/Core/DiscIO/WbfsBlob.cpp
Expand Up @@ -25,7 +25,7 @@ static const u64 WII_SECTOR_COUNT = 143432 * 2;
static const u64 WII_DISC_HEADER_SIZE = 256;

WbfsFileReader::WbfsFileReader(File::IOFile&& file, const std::string& path)
: m_total_files(0), m_size(0), m_good(false)
: m_size(0), m_good(false)
{
if (!AddFileToList(std::move(file)))
return;
Expand Down Expand Up @@ -61,7 +61,9 @@ void WbfsFileReader::OpenAdditionalFiles(const std::string& path)
{
// Replace last character with index (e.g. wbfs = wbf1)
std::string current_path = path;
current_path[current_path.length() - 1] = '0' + m_total_files;
if (m_files.size() >= 10)
return;
current_path[current_path.length() - 1] = static_cast<char>('0' + m_files.size());
if (!AddFileToList(File::IOFile(current_path, "rb")))
return;
}
Expand All @@ -77,7 +79,6 @@ bool WbfsFileReader::AddFileToList(File::IOFile&& file)
new_entry->size = new_entry->file.GetSize();
m_size += new_entry->size;

m_total_files++;
m_files.emplace_back(std::move(new_entry));

return true;
Expand Down Expand Up @@ -144,19 +145,19 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
u64 cluster_offset = offset & (m_wbfs_sector_size - 1);
u64 final_address = cluster_address + cluster_offset;

for (u32 i = 0; i != m_total_files; i++)
for (const std::unique_ptr<file_entry>& file_entry : m_files)
{
if (final_address < (m_files[i]->base_address + m_files[i]->size))
if (final_address < (file_entry->base_address + file_entry->size))
{
m_files[i]->file.Seek(final_address - m_files[i]->base_address, SEEK_SET);
file_entry->file.Seek(final_address - file_entry->base_address, SEEK_SET);
if (available)
{
u64 till_end_of_file = m_files[i]->size - (final_address - m_files[i]->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;
*available = std::min(till_end_of_file, till_end_of_sector);
}

return m_files[i]->file;
return file_entry->file;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/DiscIO/WbfsBlob.h
Expand Up @@ -50,7 +50,6 @@ class WbfsFileReader : public IBlobReader

std::vector<std::unique_ptr<file_entry>> m_files;

u32 m_total_files;
u64 m_size;

u64 m_hd_sector_size;
Expand Down

0 comments on commit 9459497

Please sign in to comment.