diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp index 0b5b56bb9c..da10f04759 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.cpp +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.cpp @@ -51,14 +51,11 @@ CFilesystemViewer::CFilesystemViewer(const std::string fileName, wxWindow* paren CreateGUIControls(); // shuffle2: things only appear in the tree for me when using debug build; why? :< - // TODO: make proper looking dirs wxTreeItemId dirId = NULL; - for(u32 a = 1; a < Our_Files.size(); ++a) - { - m_Treectrl->AppendItem(RootId, wxString::Format(_T("%s"), Our_Files[a]->m_FullPath)); + fileIter beginning = Our_Files.begin(), pos = Our_Files.begin(); + + CreateDirectoryTree(RootId, beginning, pos, "\\"); - //if(Our_Files[a]->IsDirectory()) - } m_Treectrl->Expand(RootId); // Disk header and apploader @@ -99,6 +96,40 @@ CFilesystemViewer::~CFilesystemViewer() delete OpenISO; } +void CFilesystemViewer::CreateDirectoryTree(wxTreeItemId& parent, + fileIter& begin, + fileIter& iterPos, + char *directory) +{ + //TODO(XK): Fix more than one folder/file not appearing in the root + if(iterPos == begin) + ++iterPos; + + char *name = (char *)((*iterPos)->m_FullPath); + + do + { + if((*iterPos)->IsDirectory()) { + char *dirName; + name[strlen(name) - 1] = '\0'; + dirName = strrchr(name, '\\'); + if(!dirName) + dirName = name; + else + dirName++; + //filename = strrchr(name, '\\'); ++filename; + wxTreeItemId item = m_Treectrl->AppendItem(parent, wxT(dirName)); + CreateDirectoryTree(item, begin, ++iterPos, name); + } else { + + //filename = strrchr(name, '\\'); ++filename; + m_Treectrl->AppendItem(parent, wxT(strrchr(name, '\\') + 1)); + } + ++iterPos; + name = (char *)((*iterPos)->m_FullPath); + } while(strstr(name, directory)); +} + void CFilesystemViewer::CreateGUIControls() { m_Close = new wxButton(this, ID_CLOSE, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); diff --git a/Source/Core/DolphinWX/Src/FilesystemViewer.h b/Source/Core/DolphinWX/Src/FilesystemViewer.h index 1dc2a19636..cbbf2b706a 100644 --- a/Source/Core/DolphinWX/Src/FilesystemViewer.h +++ b/Source/Core/DolphinWX/Src/FilesystemViewer.h @@ -25,6 +25,8 @@ #include #include #include + +#include "Filesystem.h" #undef FILESYSTEM_VIEWER_STYLE #define FILESYSTEM_VIEWER_STYLE wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxCLOSE_BOX @@ -132,6 +134,11 @@ class CFilesystemViewer : public wxDialog void OnExtractFile(wxCommandEvent& event); void OnReplaceFile(wxCommandEvent& event); void OnRenameFile(wxCommandEvent& event); + + typedef std::vector::iterator fileIter; + + void CreateDirectoryTree(wxTreeItemId& parent,fileIter& begin, + fileIter& iterPos, char *directory); }; #endif