Full file tree in sidebar (from cwd)

This commit is contained in:
Timothy Warren 2019-05-30 10:53:03 -04:00
parent e13373b5d9
commit b74fcf6835
2 changed files with 15 additions and 5 deletions

View File

@ -3,7 +3,6 @@
################################################################################ ################################################################################
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8)
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
project(Tyro) project(Tyro)

View File

@ -109,7 +109,7 @@ void FilePane::CreateTree(const wxString &path)
*/ */
void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent) void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent)
{ {
wxLogDebug("AddDirToTree path: %s, parent: %s", path, parent); wxLogInfo("AddDirToTree path: %s, parent: %s", path, parent);
auto fullPath = this->base_path; auto fullPath = this->base_path;
if ( ! parent.empty()) if ( ! parent.empty())
@ -153,14 +153,17 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx
wxDir::GetAllFiles(fullPath, files); wxDir::GetAllFiles(fullPath, files);
wxFileName currentPath((wxString)fullPath); wxFileName currentPath((wxString)fullPath);
currentPath.MakeAbsolute();
currentPath.MakeRelativeTo(this->base_path); currentPath.MakeRelativeTo(this->base_path);
for (const wxString &file: *files) for (const wxString &file: *files)
{ {
auto parentDir = currentPath.GetPath(); auto parentDir = currentPath.GetPath();
wxLogInfo("- Parent dir: %s, full dir: %s", parentDir, fullPath);
wxFileName fileName(file); wxFileName fileName(file);
// Make the dir relative to the base path, // Make the dir relative to the search path,
// then only use the first dir segment // then only use the first dir segment
fileName.MakeRelativeTo(fullPath); fileName.MakeRelativeTo(fullPath);
auto dir = std::string(fileName.GetPath()); auto dir = std::string(fileName.GetPath());
@ -171,12 +174,20 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx
} }
auto newParent = parentDir; auto newParent = parentDir;
if (parentDir.empty() || parentDir == ".") { if (parentDir.empty())
{
newParent = BaseName(fullPath); newParent = BaseName(fullPath);
} }
if ( ! newParent.Contains(BaseName(fullPath)))
{
newParent += "/" + BaseName(fullPath);
}
wxArrayString dirs = fileName.GetDirs(); wxArrayString dirs = fileName.GetDirs();
wxLogInfo("-- Recursing to deeper folder: %s(%s), parent: %s(%s)", dirs[0], dir, newParent, parentDir);
this->AddDirToTree(dir_node, dirs[0], newParent); this->AddDirToTree(dir_node, dirs[0], newParent);
} }
@ -189,7 +200,7 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx
void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path) void FilePane::AddDirFiles(wxTreeListItem &root, const wxString &path)
{ {
wxLogDebug("Adding files for dir: %s", path); wxLogInfo("Adding files for dir: %s", path);
auto *files = new wxArrayString(); auto *files = new wxArrayString();
wxDir::GetAllFiles(path, files, wxEmptyString, wxDIR_FILES); wxDir::GetAllFiles(path, files, wxEmptyString, wxDIR_FILES);