diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-22 22:42:05 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-03-22 22:42:05 +0100 |
commit | 47e1f28f1fe9fecf969d63f059b8ec8c0184605e (patch) | |
tree | 47ac2c6a2256b75601fa7077c994cdbfbeadc62a /plugingui/filebrowser.cc | |
parent | 70cc80a11a44c73c3cf548c7cedf2a520a025fb6 (diff) |
Added Engine->Messageing system. Implemented LoadStatus Message. Added ProgressBar widget. Made FileBrowser chdir to old value (needs further fixing). More printf->hugin ports.
Diffstat (limited to 'plugingui/filebrowser.cc')
-rw-r--r-- | plugingui/filebrowser.cc | 32 |
1 files changed, 29 insertions, 3 deletions
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 <sys/stat.h> #include <unistd.h> +#include <hugin.hpp> + #ifdef WIN32 #include <direct.h> #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) |