mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-27 06:35:39 +00:00
Check for existance of partitions instead of disc type when appropriate
This gets rid of some assumptions that non-DiscIO code was making about volume types. It's better to encapsulate as many of the volume type differences as possible in DiscIO. Made possible by PR #2353.
This commit is contained in:
parent
fbad958f03
commit
6661492989
@ -71,10 +71,11 @@ void Log(u64 offset, const DiscIO::Partition& partition)
|
|||||||
// If the volume or partition changed, load the filesystem of the new partition
|
// If the volume or partition changed, load the filesystem of the new partition
|
||||||
if (s_new_volume || s_partition != partition)
|
if (s_new_volume || s_partition != partition)
|
||||||
{
|
{
|
||||||
// Wii discs don't have PARTITION_NONE filesystems, so let's not waste time trying to read one
|
// Discs with partitions don't have PARTITION_NONE filesystems,
|
||||||
|
// so let's not waste time trying to read one
|
||||||
const bool reading_from_partition = partition != DiscIO::PARTITION_NONE;
|
const bool reading_from_partition = partition != DiscIO::PARTITION_NONE;
|
||||||
const bool is_wii_disc = s_volume->GetVolumeType() == DiscIO::Platform::WII_DISC;
|
const bool disc_has_partitions = !s_volume->GetPartitions().empty();
|
||||||
if (reading_from_partition != is_wii_disc)
|
if (reading_from_partition != disc_has_partitions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s_new_volume = false;
|
s_new_volume = false;
|
||||||
|
@ -196,53 +196,38 @@ void FilesystemPanel::CreateGUI()
|
|||||||
|
|
||||||
void FilesystemPanel::PopulateFileSystemTree()
|
void FilesystemPanel::PopulateFileSystemTree()
|
||||||
{
|
{
|
||||||
switch (m_opened_iso->GetVolumeType())
|
const std::vector<DiscIO::Partition> partitions = m_opened_iso->GetPartitions();
|
||||||
|
m_has_partitions = !partitions.empty();
|
||||||
|
|
||||||
|
if (m_has_partitions)
|
||||||
{
|
{
|
||||||
case DiscIO::Platform::GAMECUBE_DISC:
|
for (size_t i = 0; i < partitions.size(); ++i)
|
||||||
PopulateFileSystemTreeGC();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::WII_DISC:
|
|
||||||
PopulateFileSystemTreeWii();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::ELF_DOL:
|
|
||||||
case DiscIO::Platform::NUMBER_OF_PLATFORMS:
|
|
||||||
case DiscIO::Platform::WII_WAD:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::PopulateFileSystemTreeGC()
|
|
||||||
{
|
|
||||||
m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get(), DiscIO::PARTITION_NONE);
|
|
||||||
if (!m_filesystem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CreateDirectoryTree(m_tree_ctrl, m_tree_ctrl->GetRootItem(), m_filesystem->GetFileList());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::PopulateFileSystemTreeWii() const
|
|
||||||
{
|
|
||||||
std::vector<DiscIO::Partition> partitions = m_opened_iso->GetPartitions();
|
|
||||||
for (size_t i = 0; i < partitions.size(); ++i)
|
|
||||||
{
|
|
||||||
std::unique_ptr<DiscIO::IFileSystem> file_system(
|
|
||||||
DiscIO::CreateFileSystem(m_opened_iso.get(), partitions[i]));
|
|
||||||
if (file_system)
|
|
||||||
{
|
{
|
||||||
wxTreeItemId partition_root = m_tree_ctrl->AppendItem(
|
std::unique_ptr<DiscIO::IFileSystem> file_system(
|
||||||
m_tree_ctrl->GetRootItem(), wxString::Format(_("Partition %zu"), i), ICON_DISC);
|
DiscIO::CreateFileSystem(m_opened_iso.get(), partitions[i]));
|
||||||
|
if (file_system)
|
||||||
|
{
|
||||||
|
wxTreeItemId partition_root = m_tree_ctrl->AppendItem(
|
||||||
|
m_tree_ctrl->GetRootItem(), wxString::Format(_("Partition %zu"), i), ICON_DISC);
|
||||||
|
|
||||||
WiiPartition* const partition = new WiiPartition(std::move(file_system));
|
WiiPartition* const partition = new WiiPartition(std::move(file_system));
|
||||||
|
|
||||||
m_tree_ctrl->SetItemData(partition_root, partition);
|
m_tree_ctrl->SetItemData(partition_root, partition);
|
||||||
CreateDirectoryTree(m_tree_ctrl, partition_root, partition->filesystem->GetFileList());
|
CreateDirectoryTree(m_tree_ctrl, partition_root, partition->filesystem->GetFileList());
|
||||||
|
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
m_tree_ctrl->Expand(partition_root);
|
m_tree_ctrl->Expand(partition_root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_filesystem = DiscIO::CreateFileSystem(m_opened_iso.get(), DiscIO::PARTITION_NONE);
|
||||||
|
if (!m_filesystem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CreateDirectoryTree(m_tree_ctrl, m_tree_ctrl->GetRootItem(), m_filesystem->GetFileList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemPanel::OnRightClickTree(wxTreeEvent& event)
|
void FilesystemPanel::OnRightClickTree(wxTreeEvent& event)
|
||||||
@ -270,8 +255,7 @@ void FilesystemPanel::OnRightClickTree(wxTreeEvent& event)
|
|||||||
|
|
||||||
menu.Append(ID_EXTRACT_ALL, _("Extract All Files..."));
|
menu.Append(ID_EXTRACT_ALL, _("Extract All Files..."));
|
||||||
|
|
||||||
if (m_opened_iso->GetVolumeType() != DiscIO::Platform::WII_DISC ||
|
if (!m_has_partitions || (image_type == ICON_DISC && first_visible_item != selection))
|
||||||
(image_type == ICON_DISC && first_visible_item != selection))
|
|
||||||
{
|
{
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
menu.Append(ID_EXTRACT_APPLOADER, _("Extract Apploader..."));
|
menu.Append(ID_EXTRACT_APPLOADER, _("Extract Apploader..."));
|
||||||
@ -329,7 +313,7 @@ void FilesystemPanel::OnExtractHeaderData(wxCommandEvent& event)
|
|||||||
if (path.empty())
|
if (path.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_opened_iso->GetVolumeType() == DiscIO::Platform::WII_DISC)
|
if (m_has_partitions)
|
||||||
{
|
{
|
||||||
const auto* const selection_data = m_tree_ctrl->GetItemData(m_tree_ctrl->GetSelection());
|
const auto* const selection_data = m_tree_ctrl->GetItemData(m_tree_ctrl->GetSelection());
|
||||||
const auto* const partition = static_cast<const WiiPartition*>(selection_data);
|
const auto* const partition = static_cast<const WiiPartition*>(selection_data);
|
||||||
@ -360,9 +344,9 @@ void FilesystemPanel::OnExtractHeaderData(wxCommandEvent& event)
|
|||||||
|
|
||||||
void FilesystemPanel::OnCheckPartitionIntegrity(wxCommandEvent& WXUNUSED(event))
|
void FilesystemPanel::OnCheckPartitionIntegrity(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
// Normally we can't enter this function if we aren't analyzing a Wii disc
|
// Normally we can't enter this function if we're analyzing a volume that
|
||||||
// anyway, but let's still check to be sure.
|
// doesn't have partitions anyway, but let's still check to be sure.
|
||||||
if (m_opened_iso->GetVolumeType() != DiscIO::Platform::WII_DISC)
|
if (!m_has_partitions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxProgressDialog dialog(_("Checking integrity..."), _("Working..."), 1000, this,
|
wxProgressDialog dialog(_("Checking integrity..."), _("Working..."), 1000, this,
|
||||||
@ -398,122 +382,68 @@ void FilesystemPanel::OnCheckPartitionIntegrity(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void FilesystemPanel::ExtractAllFiles(const wxString& output_folder)
|
void FilesystemPanel::ExtractAllFiles(const wxString& output_folder)
|
||||||
{
|
{
|
||||||
switch (m_opened_iso->GetVolumeType())
|
if (m_has_partitions)
|
||||||
{
|
{
|
||||||
case DiscIO::Platform::GAMECUBE_DISC:
|
const wxTreeItemId root = m_tree_ctrl->GetRootItem();
|
||||||
ExtractAllFilesGC(output_folder);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::WII_DISC:
|
wxTreeItemIdValue cookie;
|
||||||
ExtractAllFilesWii(output_folder);
|
wxTreeItemId item = m_tree_ctrl->GetFirstChild(root, cookie);
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::ELF_DOL:
|
while (item.IsOk())
|
||||||
case DiscIO::Platform::NUMBER_OF_PLATFORMS:
|
{
|
||||||
case DiscIO::Platform::WII_WAD:
|
const auto* const partition = static_cast<WiiPartition*>(m_tree_ctrl->GetItemData(item));
|
||||||
break;
|
ExtractDirectories("", WxStrToStr(output_folder), partition->filesystem.get());
|
||||||
|
item = m_tree_ctrl->GetNextChild(root, cookie);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
void FilesystemPanel::ExtractAllFilesGC(const wxString& output_folder)
|
|
||||||
{
|
|
||||||
ExtractDirectories("", WxStrToStr(output_folder), m_filesystem.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::ExtractAllFilesWii(const wxString& output_folder)
|
|
||||||
{
|
|
||||||
const wxTreeItemId root = m_tree_ctrl->GetRootItem();
|
|
||||||
|
|
||||||
wxTreeItemIdValue cookie;
|
|
||||||
wxTreeItemId item = m_tree_ctrl->GetFirstChild(root, cookie);
|
|
||||||
|
|
||||||
while (item.IsOk())
|
|
||||||
{
|
{
|
||||||
const auto* const partition = static_cast<WiiPartition*>(m_tree_ctrl->GetItemData(item));
|
ExtractDirectories("", WxStrToStr(output_folder), m_filesystem.get());
|
||||||
ExtractDirectories("", WxStrToStr(output_folder), partition->filesystem.get());
|
|
||||||
item = m_tree_ctrl->GetNextChild(root, cookie);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleFile(const wxString& output_file_path) const
|
void FilesystemPanel::ExtractSingleFile(const wxString& output_file_path) const
|
||||||
{
|
{
|
||||||
const auto selection_file_path = BuildFilePathFromSelection();
|
wxString selection_file_path = BuildFilePathFromSelection();
|
||||||
|
|
||||||
switch (m_opened_iso->GetVolumeType())
|
if (m_has_partitions)
|
||||||
{
|
{
|
||||||
case DiscIO::Platform::GAMECUBE_DISC:
|
const size_t slash_index = selection_file_path.find('/');
|
||||||
ExtractSingleFileGC(selection_file_path, output_file_path);
|
const wxString partition_label = selection_file_path.substr(0, slash_index);
|
||||||
break;
|
const auto* const partition = FindWiiPartition(m_tree_ctrl, partition_label);
|
||||||
|
|
||||||
case DiscIO::Platform::WII_DISC:
|
// Remove "Partition x/"
|
||||||
ExtractSingleFileWii(selection_file_path, output_file_path);
|
selection_file_path.erase(0, slash_index + 1);
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::ELF_DOL:
|
partition->filesystem->ExportFile(WxStrToStr(selection_file_path),
|
||||||
case DiscIO::Platform::NUMBER_OF_PLATFORMS:
|
WxStrToStr(output_file_path));
|
||||||
case DiscIO::Platform::WII_WAD:
|
}
|
||||||
break;
|
else
|
||||||
|
{
|
||||||
|
m_filesystem->ExportFile(WxStrToStr(selection_file_path), WxStrToStr(output_file_path));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleFileGC(const wxString& file_path,
|
|
||||||
const wxString& output_file_path) const
|
|
||||||
{
|
|
||||||
m_filesystem->ExportFile(WxStrToStr(file_path), WxStrToStr(output_file_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleFileWii(wxString file_path,
|
|
||||||
const wxString& output_file_path) const
|
|
||||||
{
|
|
||||||
const size_t slash_index = file_path.find('/');
|
|
||||||
const wxString partition_label = file_path.substr(0, slash_index);
|
|
||||||
const auto* const partition = FindWiiPartition(m_tree_ctrl, partition_label);
|
|
||||||
|
|
||||||
// Remove "Partition x/"
|
|
||||||
file_path.erase(0, slash_index + 1);
|
|
||||||
|
|
||||||
partition->filesystem->ExportFile(WxStrToStr(file_path), WxStrToStr(output_file_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleDirectory(const wxString& output_folder)
|
void FilesystemPanel::ExtractSingleDirectory(const wxString& output_folder)
|
||||||
{
|
{
|
||||||
const wxString directory_path = BuildDirectoryPathFromSelection();
|
wxString directory_path = BuildDirectoryPathFromSelection();
|
||||||
|
|
||||||
switch (m_opened_iso->GetVolumeType())
|
if (m_has_partitions)
|
||||||
{
|
{
|
||||||
case DiscIO::Platform::GAMECUBE_DISC:
|
const size_t slash_index = directory_path.find('/');
|
||||||
ExtractSingleDirectoryGC(directory_path, output_folder);
|
const wxString partition_label = directory_path.substr(0, slash_index);
|
||||||
break;
|
const auto* const partition = FindWiiPartition(m_tree_ctrl, partition_label);
|
||||||
|
|
||||||
case DiscIO::Platform::WII_DISC:
|
// Remove "Partition x/"
|
||||||
ExtractSingleDirectoryWii(directory_path, output_folder);
|
directory_path.erase(0, slash_index + 1);
|
||||||
break;
|
|
||||||
|
|
||||||
case DiscIO::Platform::ELF_DOL:
|
ExtractDirectories(WxStrToStr(directory_path), WxStrToStr(output_folder),
|
||||||
case DiscIO::Platform::NUMBER_OF_PLATFORMS:
|
partition->filesystem.get());
|
||||||
case DiscIO::Platform::WII_WAD:
|
}
|
||||||
break;
|
else
|
||||||
|
{
|
||||||
|
ExtractDirectories(WxStrToStr(directory_path), WxStrToStr(output_folder), m_filesystem.get());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleDirectoryGC(const wxString& directory_path,
|
|
||||||
const wxString& output_folder)
|
|
||||||
{
|
|
||||||
ExtractDirectories(WxStrToStr(directory_path), WxStrToStr(output_folder), m_filesystem.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void FilesystemPanel::ExtractSingleDirectoryWii(wxString directory_path,
|
|
||||||
const wxString& output_folder)
|
|
||||||
{
|
|
||||||
const size_t slash_index = directory_path.find('/');
|
|
||||||
const wxString partition_label = directory_path.substr(0, slash_index);
|
|
||||||
const auto* const partition = FindWiiPartition(m_tree_ctrl, partition_label);
|
|
||||||
|
|
||||||
// Remove "Partition x/"
|
|
||||||
directory_path.erase(0, slash_index + 1);
|
|
||||||
|
|
||||||
ExtractDirectories(WxStrToStr(directory_path), WxStrToStr(output_folder),
|
|
||||||
partition->filesystem.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemPanel::ExtractDirectories(const std::string& full_path,
|
void FilesystemPanel::ExtractDirectories(const std::string& full_path,
|
||||||
|
@ -40,8 +40,6 @@ private:
|
|||||||
void BindEvents();
|
void BindEvents();
|
||||||
|
|
||||||
void PopulateFileSystemTree();
|
void PopulateFileSystemTree();
|
||||||
void PopulateFileSystemTreeGC();
|
|
||||||
void PopulateFileSystemTreeWii() const;
|
|
||||||
|
|
||||||
void OnRightClickTree(wxTreeEvent&);
|
void OnRightClickTree(wxTreeEvent&);
|
||||||
void OnExtractFile(wxCommandEvent&);
|
void OnExtractFile(wxCommandEvent&);
|
||||||
@ -50,17 +48,8 @@ private:
|
|||||||
void OnCheckPartitionIntegrity(wxCommandEvent&);
|
void OnCheckPartitionIntegrity(wxCommandEvent&);
|
||||||
|
|
||||||
void ExtractAllFiles(const wxString& output_folder);
|
void ExtractAllFiles(const wxString& output_folder);
|
||||||
void ExtractAllFilesGC(const wxString& output_folder);
|
|
||||||
void ExtractAllFilesWii(const wxString& output_folder);
|
|
||||||
|
|
||||||
void ExtractSingleFile(const wxString& output_file_path) const;
|
void ExtractSingleFile(const wxString& output_file_path) const;
|
||||||
void ExtractSingleFileGC(const wxString& file_path, const wxString& output_file_path) const;
|
|
||||||
void ExtractSingleFileWii(wxString file_path, const wxString& output_file_path) const;
|
|
||||||
|
|
||||||
void ExtractSingleDirectory(const wxString& output_folder);
|
void ExtractSingleDirectory(const wxString& output_folder);
|
||||||
void ExtractSingleDirectoryGC(const wxString& directory_path, const wxString& output_folder);
|
|
||||||
void ExtractSingleDirectoryWii(wxString directory_path, const wxString& output_folder);
|
|
||||||
|
|
||||||
void ExtractDirectories(const std::string& full_path, const std::string& output_folder,
|
void ExtractDirectories(const std::string& full_path, const std::string& output_folder,
|
||||||
DiscIO::IFileSystem* filesystem);
|
DiscIO::IFileSystem* filesystem);
|
||||||
|
|
||||||
@ -72,4 +61,5 @@ private:
|
|||||||
const std::unique_ptr<DiscIO::IVolume>& m_opened_iso;
|
const std::unique_ptr<DiscIO::IVolume>& m_opened_iso;
|
||||||
|
|
||||||
std::unique_ptr<DiscIO::IFileSystem> m_filesystem;
|
std::unique_ptr<DiscIO::IFileSystem> m_filesystem;
|
||||||
|
bool m_has_partitions;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user