diff options
-rw-r--r-- | backends/fs/morphos/.cvsignore | 1 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 29 | ||||
-rw-r--r-- | backends/fs/windows/.cvsignore | 1 |
3 files changed, 29 insertions, 2 deletions
diff --git a/backends/fs/morphos/.cvsignore b/backends/fs/morphos/.cvsignore new file mode 100644 index 0000000000..39a06683b7 --- /dev/null +++ b/backends/fs/morphos/.cvsignore @@ -0,0 +1 @@ +.deps diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 65e8c6bd86..0ea131b3f9 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -27,6 +27,7 @@ #endif #include <sys/stat.h> #include <dirent.h> +#include <stdio.h> /* * Implementation of the ScummVM file system API based on POSIX. @@ -119,9 +120,33 @@ FSList *POSIXFilesystemNode::listDir() const { return myList; } +const char *lastPathComponent(const ScummVM::String &str) { + const char *start = str.c_str(); + const char *cur = start + str.size() - 2; + + while (cur > start && *cur != '/') { + --cur; + } + + return cur+1; +} + FilesystemNode *POSIXFilesystemNode::parent() const { - // TODO !!! - return 0; + + POSIXFilesystemNode *p = new POSIXFilesystemNode(); + + // Root node is its own parent. Still we can't just return this + // as the GUI code will call delete on the old node. + if (_path != "/") { + const char *start = _path.c_str(); + const char *end = lastPathComponent(_path); + + p->_path = String(start, end - start); + p->_isValid = true; + p->_isDirectory = true; + p->_displayName = lastPathComponent(p->_path); + } + return p; } #endif // defined(UNIX) diff --git a/backends/fs/windows/.cvsignore b/backends/fs/windows/.cvsignore new file mode 100644 index 0000000000..39a06683b7 --- /dev/null +++ b/backends/fs/windows/.cvsignore @@ -0,0 +1 @@ +.deps |