aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/posix
diff options
context:
space:
mode:
authorMax Horn2002-11-15 17:54:38 +0000
committerMax Horn2002-11-15 17:54:38 +0000
commitfe313cea679847db4cd979f7d45cced2f732eb14 (patch)
treeb1290ae0fbf8f60de659a60402d961197be883a9 /backends/fs/posix
parentd2156bd26fb855b18db2d69642ab584aca532bd1 (diff)
downloadscummvm-rg350-fe313cea679847db4cd979f7d45cced2f732eb14.tar.gz
scummvm-rg350-fe313cea679847db4cd979f7d45cced2f732eb14.tar.bz2
scummvm-rg350-fe313cea679847db4cd979f7d45cced2f732eb14.zip
implemented parent() for POSIX fs code; added .cvsignore files
svn-id: r5571
Diffstat (limited to 'backends/fs/posix')
-rw-r--r--backends/fs/posix/posix-fs.cpp29
1 files changed, 27 insertions, 2 deletions
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)