diff options
Diffstat (limited to 'plugingui/directory.cc')
-rw-r--r-- | plugingui/directory.cc | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/plugingui/directory.cc b/plugingui/directory.cc index 9515060..5f80508 100644 --- a/plugingui/directory.cc +++ b/plugingui/directory.cc @@ -53,9 +53,12 @@ void Directory::refresh() { bool Directory::cd(std::string dir) { DEBUG(directory, "Changing to '%s'\n", dir.c_str()); - int r = chdir(dir.c_str()); - refresh(); - if(!r) return true; + int r = chdir( (path() + "/" + dir).c_str() ); + if(!r) { + _path += "/" + dir; + refresh(); + return true; + } else return false; } @@ -81,7 +84,32 @@ std::string Directory::cwd() { } std::string Directory::cleanPath(std::string path) { - // TODO! +/* + size_t c = 0; + std::string current_char; + std::string prev_char; + + for(; c < path.size(); c++) { + current_char = path.at(c); + prev_char = current_char; + } +*/ +/* + + size_t current_pos; + size_t prev_pos = 1; + DEBUG(directory, "Looking at path '%s'\n", path.c_str()); + while( (current_pos = path.find("/", prev_pos + 1)) != std::string::npos) { + DEBUG(directory, "%d - %d", prev_pos, current_pos); + std::string dir = path.substr(prev_pos, current_pos - prev_pos + 1); + DEBUG(directory, "Dir '%s'\n", dir.c_str()); + prev_pos = current_pos; + } + + std::string dir = path.substr(prev_pos, current_pos - prev_pos + 1); + DEBUG(directory, "Dir '%s'\n", dir.c_str()); +*/ + return path; } |