summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2015-07-29 16:42:29 +0200
committerJosJuice <josjuice@gmail.com>2017-06-13 22:38:31 +0200
commit07d3a39aeb06204e13cfdf1d5f7dbe4f3aa66f89 (patch)
tree5cb05fd42f2f5da5319d32a73cd2856ad5d18b61 /Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp
parent5021b4a567fad9a258f2b0fc397912f499e4cb1d (diff)
Filesystem: Replace file info's full path with name
Some callers (i.e. ISOProperties) don't want the full path, so giving them it is unnecessary. Those that do want it can use GetPathFromFSTOffset. Not storing full paths everywhere also saves a small bit of RAM and is necessary for a later commit. The code isn't especially pretty right now (callers need to use FST offsets...) but it'll become better later.
Diffstat (limited to 'Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp')
-rw-r--r--Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp b/Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp
index 4b1f5d330a..ebad7364ef 100644
--- a/Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp
+++ b/Source/Core/DolphinWX/ISOProperties/FilesystemPanel.cpp
@@ -94,32 +94,18 @@ size_t CreateDirectoryTree(wxTreeCtrl* tree_ctrl, wxTreeItemId parent,
while (current_index < last_index)
{
const DiscIO::FileInfoGCWii& file_info = file_infos[current_index];
- std::string file_path = file_info.m_FullPath;
-
- // Trim the trailing '/' if it exists.
- if (file_path.back() == DIR_SEP_CHR)
- {
- file_path.pop_back();
- }
-
- // Cut off the path up to the actual filename or folder.
- // Say we have "/music/stream/stream1.strm", the result will be "stream1.strm".
- const size_t dir_sep_index = file_path.rfind(DIR_SEP_CHR);
- if (dir_sep_index != std::string::npos)
- {
- file_path = file_path.substr(dir_sep_index + 1);
- }
// check next index
if (file_info.IsDirectory())
{
- const wxTreeItemId item = tree_ctrl->AppendItem(parent, StrToWxStr(file_path), ICON_FOLDER);
+ const wxTreeItemId item =
+ tree_ctrl->AppendItem(parent, StrToWxStr(file_info.GetName()), ICON_FOLDER);
current_index = CreateDirectoryTree(tree_ctrl, item, file_infos, current_index + 1,
static_cast<size_t>(file_info.GetSize()));
}
else
{
- tree_ctrl->AppendItem(parent, StrToWxStr(file_path), ICON_FILE);
+ tree_ctrl->AppendItem(parent, StrToWxStr(file_info.GetName()), ICON_FILE);
current_index++;
}
}
@@ -472,7 +458,7 @@ void FilesystemPanel::ExtractDirectories(const std::string& full_path,
// Look for the dir we are going to extract
for (index = 0; index < fst.size(); ++index)
{
- if (fst[index].m_FullPath == full_path)
+ if (filesystem->GetPathFromFSTOffset(index) == full_path)
{
INFO_LOG(DISCIO, "Found the directory at %u", index);
size = static_cast<u32>(fst[index].GetSize());
@@ -492,12 +478,13 @@ void FilesystemPanel::ExtractDirectories(const std::string& full_path,
// Extraction
for (u32 i = index; i < size; i++)
{
+ const std::string path = filesystem->GetPathFromFSTOffset(i);
dialog.SetTitle(wxString::Format(
"%s : %u%%", dialog_title.c_str(),
static_cast<u32>((static_cast<float>(i - index) / static_cast<float>(size - index)) *
100)));
- dialog.Update(i, wxString::Format(_("Extracting %s"), StrToWxStr(fst[i].m_FullPath)));
+ dialog.Update(i, wxString::Format(_("Extracting %s"), StrToWxStr(path)));
if (dialog.WasCancelled())
break;
@@ -505,7 +492,7 @@ void FilesystemPanel::ExtractDirectories(const std::string& full_path,
if (fst[i].IsDirectory())
{
const std::string export_name =
- StringFromFormat("%s/%s/", output_folder.c_str(), fst[i].m_FullPath.c_str());
+ StringFromFormat("%s/%s/", output_folder.c_str(), path.c_str());
INFO_LOG(DISCIO, "%s", export_name.c_str());
if (!File::Exists(export_name) && !File::CreateFullPath(export_name))
@@ -523,10 +510,10 @@ void FilesystemPanel::ExtractDirectories(const std::string& full_path,
else
{
const std::string export_name =
- StringFromFormat("%s/%s", output_folder.c_str(), fst[i].m_FullPath.c_str());
+ StringFromFormat("%s/%s", output_folder.c_str(), path.c_str());
INFO_LOG(DISCIO, "%s", export_name.c_str());
- if (!File::Exists(export_name) && !filesystem->ExportFile(fst[i].m_FullPath, export_name))
+ if (!File::Exists(export_name) && !filesystem->ExportFile(path, export_name))
{
ERROR_LOG(DISCIO, "Could not export %s", export_name.c_str());
}