summaryrefslogtreecommitdiff
path: root/plugingui/directory.cc
diff options
context:
space:
mode:
authorjsc@umbraculum.org <jsc@umbraculum.org>2013-04-26 15:22:49 +0200
committerjsc@umbraculum.org <jsc@umbraculum.org>2013-04-26 15:22:49 +0200
commit2eedb967d2a3f8026163bd182e973106e6846a13 (patch)
tree71922ee5a65fa5d3af2719b4c853466eae27d5c5 /plugingui/directory.cc
parentdda686a04556a4cbbed0d8acf68c7d017b613024 (diff)
Setting directory to previous selected directory when selecting new file.
Diffstat (limited to 'plugingui/directory.cc')
-rw-r--r--plugingui/directory.cc44
1 files changed, 28 insertions, 16 deletions
diff --git a/plugingui/directory.cc b/plugingui/directory.cc
index be5fad9..d25a367 100644
--- a/plugingui/directory.cc
+++ b/plugingui/directory.cc
@@ -92,22 +92,7 @@ std::string Directory::cleanPath(std::string path) {
WARN(directory, "Cleaning path '%s'\n", path.c_str());
Directory::Path pathlst = parsePath(path);
-
- std::string cleaned_path;
- DEBUG(directory, "Number of directories in path %d\n", pathlst.size());
-
- for(Directory::Path::iterator it = pathlst.begin();
- it != pathlst.end(); it++) {
- std::string dir = *it;
- DEBUG(directory, "\tDir '%s'\n", dir.c_str());
- cleaned_path += "/" + dir;
- }
-
- DEBUG(directory, "Cleaned path '%s'\n", cleaned_path.c_str());
-
- if(cleaned_path.empty()) cleaned_path = "/";
-
- return cleaned_path;
+ return Directory::pathToStr(pathlst);
}
Directory::EntryList Directory::listFiles(std::string path) {
@@ -234,6 +219,33 @@ Directory::Path Directory::parsePath(std::string path_str) {
return path;
}
+std::string Directory::pathToStr(Directory::Path& path) {
+ std::string cleaned_path;
+ DEBUG(directory, "Number of directories in path %d\n", path.size());
+
+ for(Directory::Path::iterator it = path.begin();
+ it != path.end(); it++) {
+ std::string dir = *it;
+ DEBUG(directory, "\tDir '%s'\n", dir.c_str());
+ cleaned_path += "/" + dir;
+ }
+
+ DEBUG(directory, "Cleaned path '%s'\n", cleaned_path.c_str());
+
+ if(cleaned_path.empty()) cleaned_path = "/";
+
+ return cleaned_path;
+}
+
+std::string Directory::pathDirectory(std::string filepath) {
+ if(Directory::isDir(filepath)) return filepath;
+
+ Directory::Path path = parsePath(filepath);
+ if(path.size() > 0) path.pop_back();
+
+ return Directory::pathToStr(path);
+}
+
#ifdef TEST_DIRECTORY
//Additional dependency files
//deps: