From 47e1f28f1fe9fecf969d63f059b8ec8c0184605e Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 22 Mar 2013 22:42:05 +0100 Subject: Added Engine->Messageing system. Implemented LoadStatus Message. Added ProgressBar widget. Made FileBrowser chdir to old value (needs further fixing). More printf->hugin ports. --- plugingui/filebrowser.cc | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'plugingui/filebrowser.cc') diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc index afd6518..7efd050 100644 --- a/plugingui/filebrowser.cc +++ b/plugingui/filebrowser.cc @@ -38,6 +38,8 @@ #include #include +#include + #ifdef WIN32 #include #endif @@ -189,9 +191,33 @@ GUI::FileBrowser::~FileBrowser() void GUI::FileBrowser::setPath(std::string path) { - int i = chdir(path.c_str()); - (void)i; - changeDir(prv); + std::string dirname = path; + + while(dirname != "") { + + DEBUG(filebrowser, "dirname: %s\n", dirname.c_str()); + + struct stat st; + if(stat(dirname.c_str(), &st) == 0) { + if((st.st_mode & S_IFDIR) != 0) { + dirname += "/."; + int i = chdir(dirname.c_str()); + (void)i; + changeDir(prv); + + DEBUG(filebrowser, "chdir to: %s\n", dirname.c_str()); + + return; + } + } + + dirname = dirname.substr(0, dirname.length() - 1); + while(dirname[dirname.length() - 1] != '/' && + dirname[dirname.length() - 1] != '\\' && + dirname != "") { + dirname = dirname.substr(0, dirname.length() - 1); + } + } } void GUI::FileBrowser::resize(size_t w, size_t h) -- cgit v1.2.3