summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2014-03-23 00:34:26 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2014-03-23 00:34:26 -0500
commita3e18cd498e6a02dfd615da25e975f110e8cf365 (patch)
tree63d4fabcda7d8d4ddfa1982cc406acf010cb1132 /Source/Core/DolphinWX
parentb8f469dedd155f6fd42239cdf22f239037da6fce (diff)
parentbd1ce18f9092f2929929513729e8abee8f60e4a5 (diff)
Merge pull request #171 from lioncash/rarc-cleanup
File tree building cleanup
Diffstat (limited to 'Source/Core/DolphinWX')
-rw-r--r--Source/Core/DolphinWX/ISOProperties.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp
index 02537df1fe..f3076c56f0 100644
--- a/Source/Core/DolphinWX/ISOProperties.cpp
+++ b/Source/Core/DolphinWX/ISOProperties.cpp
@@ -320,30 +320,32 @@ size_t CISOProperties::CreateDirectoryTree(wxTreeItemId& parent,
while (CurrentIndex < _LastIndex)
{
- const DiscIO::SFileInfo *rFileInfo = fileInfos[CurrentIndex];
- char *name = (char*)rFileInfo->m_FullPath;
+ const DiscIO::SFileInfo* rFileInfo = fileInfos[CurrentIndex];
+ std::string filePath = rFileInfo->m_FullPath;
- if (rFileInfo->IsDirectory())
+ // Trim the trailing '/' if it exists.
+ if (filePath[filePath.length() - 1] == DIR_SEP_CHR)
{
- name[strlen(name) - 1] = '\0';
+ filePath.pop_back();
}
- char *itemName = strrchr(name, DIR_SEP_CHR);
-
- if (!itemName)
- itemName = name;
- else
- itemName++;
+ // Cut off the path up to the actual filename or folder.
+ // Say we have "/music/stream/stream1.strm", the result will be "stream1.strm".
+ size_t dirSepIndex = filePath.find_last_of(DIR_SEP_CHR);
+ if (dirSepIndex != std::string::npos)
+ {
+ filePath = filePath.substr(dirSepIndex + 1);
+ }
// check next index
if (rFileInfo->IsDirectory())
{
- wxTreeItemId item = m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 1, 1);
+ wxTreeItemId item = m_Treectrl->AppendItem(parent, StrToWxStr(filePath), 1, 1);
CurrentIndex = CreateDirectoryTree(item, fileInfos, CurrentIndex + 1, (size_t)rFileInfo->m_FileSize);
}
else
{
- m_Treectrl->AppendItem(parent, StrToWxStr(itemName), 2, 2);
+ m_Treectrl->AppendItem(parent, StrToWxStr(filePath), 2, 2);
CurrentIndex++;
}
}
@@ -740,7 +742,7 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
if (DiscIO::IsVolumeWiiDisc(OpenISO))
{
int partitionNum = wxAtoi(File.Mid(File.find_first_of("/") - 1, 1));
- File.Remove(0, File.find_first_of("/") +1); // Remove "Partition x/"
+ File.Remove(0, File.find_first_of("/") + 1); // Remove "Partition x/"
WiiDisc.at(partitionNum).FileSystem->ExportFile(WxStrToStr(File), WxStrToStr(Path));
}
else
@@ -751,7 +753,7 @@ void CISOProperties::OnExtractFile(wxCommandEvent& WXUNUSED (event))
void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolder, const int partitionNum)
{
- char exportName[512];
+ std::string exportName;
u32 index[2] = {0, 0};
std::vector<const DiscIO::SFileInfo *> fst;
DiscIO::IFileSystem *FS = nullptr;
@@ -780,7 +782,7 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
{
for (index[0] = 0; index[0] < fst.size(); index[0]++)
{
- if (!strcmp(fst.at(index[0])->m_FullPath, _rFullPath))
+ if (fst.at(index[0])->m_FullPath == _rFullPath)
{
DEBUG_LOG(DISCIO, "Found the directory at %u", index[0]);
index[1] = (u32)fst.at(index[0])->m_FileSize;
@@ -808,41 +810,40 @@ void CISOProperties::ExportDir(const char* _rFullPath, const char* _rExportFolde
dialog.SetTitle(wxString::Format(wxT("%s : %d%%"), dialogTitle.c_str(),
(u32)(((float)(i - index[0]) / (float)(index[1] - index[0])) * 100)));
- dialog.Update(i, wxString::Format(_("Extracting %s"),
- StrToWxStr(fst[i]->m_FullPath)));
+ dialog.Update(i, wxString::Format(_("Extracting %s"), StrToWxStr(fst[i]->m_FullPath)));
if (dialog.WasCancelled())
break;
if (fst[i]->IsDirectory())
{
- snprintf(exportName, sizeof(exportName), "%s/%s/", _rExportFolder, fst[i]->m_FullPath);
- DEBUG_LOG(DISCIO, "%s", exportName);
+ exportName = StringFromFormat("%s/%s/", _rExportFolder, fst[i]->m_FullPath.c_str());
+ DEBUG_LOG(DISCIO, "%s", exportName.c_str());
if (!File::Exists(exportName) && !File::CreateFullPath(exportName))
{
- ERROR_LOG(DISCIO, "Could not create the path %s", exportName);
+ ERROR_LOG(DISCIO, "Could not create the path %s", exportName.c_str());
}
else
{
if (!File::IsDirectory(exportName))
- ERROR_LOG(DISCIO, "%s already exists and is not a directory", exportName);
+ ERROR_LOG(DISCIO, "%s already exists and is not a directory", exportName.c_str());
- DEBUG_LOG(DISCIO, "Folder %s already exists", exportName);
+ DEBUG_LOG(DISCIO, "Folder %s already exists", exportName.c_str());
}
}
else
{
- snprintf(exportName, sizeof(exportName), "%s/%s", _rExportFolder, fst[i]->m_FullPath);
- DEBUG_LOG(DISCIO, "%s", exportName);
+ exportName = StringFromFormat("%s/%s", _rExportFolder, fst[i]->m_FullPath.c_str());
+ DEBUG_LOG(DISCIO, "%s", exportName.c_str());
if (!File::Exists(exportName) && !FS->ExportFile(fst[i]->m_FullPath, exportName))
{
- ERROR_LOG(DISCIO, "Could not export %s", exportName);
+ ERROR_LOG(DISCIO, "Could not export %s", exportName.c_str());
}
else
{
- DEBUG_LOG(DISCIO, "%s already exists", exportName);
+ DEBUG_LOG(DISCIO, "%s already exists", exportName.c_str());
}
}
}
@@ -869,8 +870,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
while (m_Treectrl->GetItemParent(m_Treectrl->GetSelection()) != m_Treectrl->GetRootItem())
{
- wxString temp;
- temp = m_Treectrl->GetItemText(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
+ wxString temp = m_Treectrl->GetItemText(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
Directory = temp + wxT(DIR_SEP_CHR) + Directory;
m_Treectrl->SelectItem(m_Treectrl->GetItemParent(m_Treectrl->GetSelection()));
@@ -879,7 +879,7 @@ void CISOProperties::OnExtractDir(wxCommandEvent& event)
if (DiscIO::IsVolumeWiiDisc(OpenISO))
{
int partitionNum = wxAtoi(Directory.Mid(Directory.find_first_of("/") - 1, 1));
- Directory.Remove(0, Directory.find_first_of("/") +1); // Remove "Partition x/"
+ Directory.Remove(0, Directory.find_first_of("/") + 1); // Remove "Partition x/"
ExportDir(WxStrToStr(Directory).c_str(), WxStrToStr(Path).c_str(), partitionNum);
}
else
@@ -899,7 +899,7 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
if (DiscIO::IsVolumeWiiDisc(OpenISO))
{
wxString Directory = m_Treectrl->GetItemText(m_Treectrl->GetSelection());
- std::size_t partitionNum = (std::size_t)wxAtoi(Directory.Mid(Directory.find_first_of("0123456789"), 2));
+ int partitionNum = wxAtoi(Directory.Mid(Directory.find_first_of("0123456789"), 2));
if (WiiDisc.size() > partitionNum)
{
@@ -908,7 +908,7 @@ void CISOProperties::OnExtractDataFromHeader(wxCommandEvent& event)
}
else
{
- PanicAlertT("Partition doesn't exist: %u", (unsigned) partitionNum);
+ PanicAlertT("Partition doesn't exist: %d", partitionNum);
return;
}
}