[Scummvm-cvs-logs] CVS: scummvm/backends/fs/posix posix-fs.cpp,1.18,1.19
Max Horn
fingolfin at users.sourceforge.net
Sat Nov 20 13:36:16 CET 2004
Update of /cvsroot/scummvm/scummvm/backends/fs/posix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32450/backends/fs/posix
Modified Files:
posix-fs.cpp
Log Message:
Changed the FilesystemNode implementation to make it easier to use (client code doesn't have to worry about the memory managment anymore, it's all 'automatic' now). May have introduced a mem leak or two, please check :-)
Index: posix-fs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/fs/posix/posix-fs.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- posix-fs.cpp 1 Feb 2004 01:31:50 -0000 1.18
+++ posix-fs.cpp 20 Nov 2004 21:35:48 -0000 1.19
@@ -45,7 +45,7 @@
* Implementation of the ScummVM file system API based on POSIX.
*/
-class POSIXFilesystemNode : public FilesystemNode {
+class POSIXFilesystemNode : public AbstractFilesystemNode {
protected:
String _displayName;
bool _isDirectory;
@@ -62,9 +62,8 @@
virtual bool isDirectory() const { return _isDirectory; }
virtual String path() const { return _path; }
- virtual FSList *listDir(ListMode mode = kListDirectoriesOnly) const;
- virtual FilesystemNode *parent() const;
- virtual FilesystemNode *clone() const { return new POSIXFilesystemNode(this); }
+ virtual FSList listDir(ListMode mode = kListDirectoriesOnly) const;
+ virtual AbstractFilesystemNode *parent() const;
};
@@ -79,12 +78,12 @@
return cur+1;
}
-FilesystemNode *FilesystemNode::getRoot() {
+AbstractFilesystemNode *FilesystemNode::getRoot() {
return new POSIXFilesystemNode();
}
#ifdef MACOSX
-FilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
+AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
return new POSIXFilesystemNode(path);
}
#endif
@@ -140,15 +139,16 @@
_path = node->_path;
}
-FSList *POSIXFilesystemNode::listDir(ListMode mode) const {
+FSList POSIXFilesystemNode::listDir(ListMode mode) const {
assert(_isDirectory);
DIR *dirp = opendir(_path.c_str());
struct stat st;
struct dirent *dp;
- FSList *myList = new FSList();
+ FSList myList;
- if (dirp == NULL) return myList;
+ if (dirp == NULL)
+ return myList;
// ... loop over dir entries using readdir
while ((dp = readdir(dirp)) != NULL) {
@@ -178,13 +178,13 @@
if (entry._isDirectory)
entry._path += "/";
- myList->push_back(entry);
+ myList.push_back(wrap(new POSIXFilesystemNode(&entry)));
}
closedir(dirp);
return myList;
}
-FilesystemNode *POSIXFilesystemNode::parent() const {
+AbstractFilesystemNode *POSIXFilesystemNode::parent() const {
POSIXFilesystemNode *p = new POSIXFilesystemNode();
// Root node is its own parent. Still we can't just return this
More information about the Scummvm-git-logs
mailing list