[Scummvm-cvs-logs] CVS: scummvm/backends/fs/posix posix-fs.cpp,1.4,1.5
Max Horn
fingolfin at users.sourceforge.net
Fri Nov 15 09:55:04 CET 2002
Update of /cvsroot/scummvm/scummvm/backends/fs/posix
In directory usw-pr-cvs1:/tmp/cvs-serv30452/posix
Modified Files:
posix-fs.cpp
Log Message:
implemented parent() for POSIX fs code; added .cvsignore files
Index: posix-fs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/fs/posix/posix-fs.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- posix-fs.cpp 15 Nov 2002 17:05:50 -0000 1.4
+++ posix-fs.cpp 15 Nov 2002 17:54:38 -0000 1.5
@@ -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 @@
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)
More information about the Scummvm-git-logs
mailing list