[Scummvm-cvs-logs] SF.net SVN: scummvm: [22300] scummvm/trunk/backends/fs

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed May 3 04:14:29 CEST 2006


Revision: 22300
Author:   fingolfin
Date:     2006-05-03 04:13:21 -0700 (Wed, 03 May 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22300&view=rev

Log Message:
-----------
Got rid of AbstractFilesystemNode::wrap (begone, evil hack)

Modified Paths:
--------------
    scummvm/trunk/backends/fs/abstract-fs.h
    scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
    scummvm/trunk/backends/fs/fs.cpp
    scummvm/trunk/backends/fs/fs.h
    scummvm/trunk/backends/fs/morphos/abox-fs.cpp
    scummvm/trunk/backends/fs/palmos/palmos-fs.cpp
    scummvm/trunk/backends/fs/posix/posix-fs.cpp
    scummvm/trunk/backends/fs/ps2/ps2-fs.cpp
    scummvm/trunk/backends/fs/symbian/symbian-fs.cpp
    scummvm/trunk/backends/fs/windows/windows-fs.cpp
Modified: scummvm/trunk/backends/fs/abstract-fs.h
===================================================================
--- scummvm/trunk/backends/fs/abstract-fs.h	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/abstract-fs.h	2006-05-03 11:13:21 UTC (rev 22300)
@@ -22,10 +22,15 @@
 #ifndef BACKENDS_ABSTRACT_FS_H
 #define BACKENDS_ABSTRACT_FS_H
 
+#include "common/array.h"
 #include "common/str.h"
 
 #include "backends/fs/fs.h"
 
+class AbstractFilesystemNode;
+
+typedef Common::Array<AbstractFilesystemNode *>	AbstractFSList;
+
 /**
  * Abstract file system node. Private subclasses implement the actual
  * functionality.
@@ -50,16 +55,6 @@
 	virtual AbstractFilesystemNode *child(const String &name) const = 0;
 
 	/**
-	 * This method is a rather ugly hack which is used internally by the
-	 * actual node implementions to wrap up raw nodes inside FilesystemNode
-	 * objects. We probably want to get rid of this eventually and replace it
-	 * with a cleaner / more elegant solution, but for now it works.
-	 * @note This takes over ownership of node. Do not delete it yourself,
-	 *       else you'll get ugly crashes. You've been warned!
-	 */
-	static FilesystemNode wrap(AbstractFilesystemNode *node);
-
-	/**
 	 * Returns a special node representing the FS root. The starting point for
 	 * any file system browsing.
 	 * On Unix, this will be simply the node for / (the root directory).
@@ -126,7 +121,7 @@
 	 * on a node that does not represent a directory, an error is triggered.
 	 * @todo Rename this to listChildren.
 	 */
-	virtual FSList listDir(ListMode mode) const = 0;
+	virtual AbstractFSList listDir(ListMode mode) const = 0;
 
 
 	/* TODO:

Modified: scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/amigaos4/amigaos4-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -69,8 +69,8 @@
 		virtual bool isDirectory() const { return _bIsDirectory; };
 		virtual String path() const { return _sPath; };
 
-		virtual FSList listDir(ListMode mode) const;
-		virtual FSList listVolumes(void) const;
+		virtual AbstractFSList listDir(ListMode mode) const;
+		virtual AbstractFSList listVolumes(void) const;
 		virtual AbstractFilesystemNode *parent() const;
 		virtual AbstractFilesystemNode *child(const String &name) const;
 };
@@ -222,10 +222,10 @@
 	LEAVE();
 }
 
-FSList AmigaOSFilesystemNode::listDir(ListMode mode) const {
+AbstractFSList AmigaOSFilesystemNode::listDir(ListMode mode) const {
 	ENTER();
 
-	FSList myList;
+	AbstractFSList myList;
 
 	if (!_bIsValid) {
 		debug(6, "Invalid node");
@@ -275,7 +275,7 @@
 							AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
 							if (entry) {
 								if (entry->isValid())
-								    myList.push_back(wrap(entry));
+								    myList.push_back(entry);
 								else
 									delete entry;
 							}
@@ -334,10 +334,10 @@
 	return new AmigaOSFilesystemNode(newPath);
 }
 
-FSList AmigaOSFilesystemNode::listVolumes(void)	const {
+AbstractFSList AmigaOSFilesystemNode::listVolumes(void)	const {
 	ENTER();
 
-	FSList myList;
+	AbstractFSList myList;
 
 	const uint32 kLockFlags = LDF_READ | LDF_VOLUMES;
 	char name[MAXPATHLEN];
@@ -367,7 +367,7 @@
 				AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, name);
 				if (entry) {
 					if (entry->isValid())
-						myList.push_back(wrap(entry));
+						myList.push_back(entry);
 					else
 						delete entry;
 				}

Modified: scummvm/trunk/backends/fs/fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -29,11 +29,6 @@
 static AbstractFilesystemNode *_rootNode = 0;
 static int *_rootRefCount = 0;
 
-FilesystemNode AbstractFilesystemNode::wrap(AbstractFilesystemNode *node) {
-	FilesystemNode wrapper(node);
-	return wrapper;
-}
-
 FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
 	_realNode = realNode;
 	_refCount = new int(1);
@@ -91,7 +86,7 @@
 	if (node == 0) {
 		return *this;
 	} else {
-		return AbstractFilesystemNode::wrap(node);
+		return FilesystemNode(node);
 	}
 }
 
@@ -101,13 +96,20 @@
 
 	assert(_realNode->isDirectory());
 	AbstractFilesystemNode *node = _realNode->child(name);
-	return AbstractFilesystemNode::wrap(node);
+	return FilesystemNode(node);
 }
 
 FSList FilesystemNode::listDir(ListMode mode) const {
 	assert(_realNode);
 	assert(_realNode->isDirectory());
-	return _realNode->listDir(mode);
+	AbstractFSList inList(_realNode->listDir(mode));
+	FSList outList;
+	
+	for (AbstractFSList::iterator i = inList.begin(); i != inList.end(); ++i) {
+		outList.push_back(FilesystemNode(*i));
+	}
+	
+	return outList;
 }
 
 Common::String FilesystemNode::displayName() const {

Modified: scummvm/trunk/backends/fs/fs.h
===================================================================
--- scummvm/trunk/backends/fs/fs.h	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/fs.h	2006-05-03 11:13:21 UTC (rev 22300)
@@ -68,8 +68,6 @@
 
 
 class FilesystemNode {
-	friend class AbstractFilesystemNode;
-
 	typedef Common::String String;
 private:
 	AbstractFilesystemNode *_realNode;

Modified: scummvm/trunk/backends/fs/morphos/abox-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/morphos/abox-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/morphos/abox-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -51,8 +51,8 @@
 		virtual bool isDirectory() const { return _isDirectory; }
 		virtual String path() const { return _path; }
 
-		virtual FSList listDir(ListMode mode) const;
-		static  FSList listRoot();
+		virtual AbstractFSList listDir(ListMode mode) const;
+		static  AbstractFSList listRoot();
 		virtual AbstractFilesystemNode *parent() const;
 		virtual AbstractFilesystemNode *child(const String &name) const;
 };
@@ -129,9 +129,9 @@
 	}
 }
 
-FSList ABoxFilesystemNode::listDir(ListMode mode) const
+AbstractFSList ABoxFilesystemNode::listDir(ListMode mode) const
 {
-	FSList myList;
+	AbstractFSList myList;
 
 	if (!_isValid)
 		error("listDir() called on invalid node");
@@ -174,7 +174,7 @@
 					if (entry)
 					{
 						if (entry->isValid())
-							myList.push_back(wrap(entry));
+							myList.push_back(entry);
 						else
 							delete entry;
 					}
@@ -218,9 +218,9 @@
 	TODO
 }
 
-FSList ABoxFilesystemNode::listRoot()
+AbstractFSList ABoxFilesystemNode::listRoot()
 {
-	FSList myList;
+	AbstractFSList myList;
 	DosList *dosList;
 	CONST ULONG lockDosListFlags = LDF_READ | LDF_VOLUMES;
 	char name[256];
@@ -255,7 +255,7 @@
 				if (entry)
 				{
 					if (entry->isValid())
-						myList.push_back(wrap(entry));
+						myList.push_back(entry);
 					else
 						delete entry;
 				}

Modified: scummvm/trunk/backends/fs/palmos/palmos-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/palmos/palmos-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/palmos/palmos-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -48,15 +48,15 @@
 	virtual bool isDirectory() const { return _isDirectory; }
 	virtual String path() const { return _path; }
 
-	virtual FSList listDir(ListMode) const;
+	virtual AbstractFSList listDir(ListMode) const;
 	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *child(const String &name) const;
 
 private:
-	static void addFile (FSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
+	static void addFile (AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
 };
 
-void PalmOSFilesystemNode::addFile(FSList &list, ListMode mode, const char *base, FileInfoType* find_data) {
+void PalmOSFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, FileInfoType* find_data) {
 	PalmOSFilesystemNode entry;
 	bool isDirectory;
 
@@ -75,7 +75,7 @@
 
 	entry._isValid = true;	
 	entry._isPseudoRoot = false;
-	list.push_back(wrap(new PalmOSFilesystemNode(entry)));
+	list.push_back(new PalmOSFilesystemNode(entry));
 }
 
 AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
@@ -116,8 +116,8 @@
 	_path = node._path;
 }
 
-FSList PalmOSFilesystemNode::listDir(ListMode mode) const {
-	FSList myList;
+AbstractFSList PalmOSFilesystemNode::listDir(ListMode mode) const {
+	AbstractFSList myList;
 	Err e;
 	Char nameP[256];
 	FileInfoType desc;

Modified: scummvm/trunk/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/posix/posix-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/posix/posix-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -57,7 +57,7 @@
 	virtual bool isDirectory() const { return _isDirectory; }
 	virtual String path() const { return _path; }
 
-	virtual FSList listDir(ListMode mode) const;
+	virtual AbstractFSList listDir(ListMode mode) const;
 	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *child(const String &name) const;
 };
@@ -130,12 +130,12 @@
 	}
 }
 
-FSList POSIXFilesystemNode::listDir(ListMode mode) const {
+AbstractFSList POSIXFilesystemNode::listDir(ListMode mode) const {
 	assert(_isDirectory);
 	DIR *dirp = opendir(_path.c_str());
 
 	struct dirent *dp;
-	FSList myList;
+	AbstractFSList myList;
 
 	if (dirp == NULL)
 		return myList;
@@ -192,7 +192,7 @@
 
 		if (entry._isDirectory)
 			entry._path += "/";
-		myList.push_back(wrap(new POSIXFilesystemNode(entry)));
+		myList.push_back(new POSIXFilesystemNode(entry));
 	}
 	closedir(dirp);
 	return myList;

Modified: scummvm/trunk/backends/fs/ps2/ps2-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/ps2/ps2-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/ps2/ps2-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -45,7 +45,7 @@
 	virtual bool isDirectory() const { return _isDirectory; }
 	virtual String path() const { return _path; }
 
-	virtual FSList listDir(ListMode) const;
+	virtual AbstractFSList listDir(ListMode) const;
 	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *child(const String &name) const;
 
@@ -79,10 +79,10 @@
 	_isDirectory = true;
 }
 
-FSList Ps2FilesystemNode::listDir(ListMode mode) const {
+AbstractFSList Ps2FilesystemNode::listDir(ListMode mode) const {
 	assert(_isDirectory);
 
-	FSList myList;
+	AbstractFSList myList;
 
 	struct TocEntry tocEntries[MAX_LIST_ENTRIES];
 	int files;
@@ -112,7 +112,7 @@
 			dirEntry._path += tocEntries[fCnt].filename;
 
 			dirEntry._displayName = tocEntries[fCnt].filename;
-			myList.push_back(wrap(new Ps2FilesystemNode(dirEntry)));
+			myList.push_back(new Ps2FilesystemNode(dirEntry));
 		}
 	}
 	return myList;

Modified: scummvm/trunk/backends/fs/symbian/symbian-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/symbian/symbian-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/symbian/symbian-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -52,7 +52,7 @@
 	virtual bool isDirectory() const { return _isDirectory; }
 	virtual String path() const { return _path; }
 
-	virtual FSList listDir(ListMode mode) const;
+	virtual AbstractFSList listDir(ListMode mode) const;
 	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *child(const String &name) const;
 };
@@ -105,9 +105,9 @@
 	_isDirectory = true;
 }
 
-FSList SymbianFilesystemNode::listDir(ListMode mode) const {
+AbstractFSList SymbianFilesystemNode::listDir(ListMode mode) const {
 	assert(_isDirectory);
-	FSList myList;
+	AbstractFSList myList;
 
 	if (_isPseudoRoot) {
 		// Drives enumeration
@@ -144,7 +144,7 @@
 			entry._isValid = true;
 			entry._isPseudoRoot = false;
 			entry._path = path;
-			myList.push_back(wrap(new SymbianFilesystemNode(entry)));
+			myList.push_back(new SymbianFilesystemNode(entry));
 		}
 	} else {
 		TPtrC8 ptr((const unsigned char*)_path.c_str(),_path.size());
@@ -173,7 +173,7 @@
 				
 				if (entry._isDirectory)
 					entry._path += "\\";
-				myList.push_back(wrap(new SymbianFilesystemNode(entry)));
+				myList.push_back(new SymbianFilesystemNode(entry));
 			}
 			CleanupStack::PopAndDestroy(dirPtr);
 		}

Modified: scummvm/trunk/backends/fs/windows/windows-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/windows/windows-fs.cpp	2006-05-03 10:48:18 UTC (rev 22299)
+++ scummvm/trunk/backends/fs/windows/windows-fs.cpp	2006-05-03 11:13:21 UTC (rev 22300)
@@ -50,14 +50,14 @@
 	virtual bool isDirectory() const { return _isDirectory; }
 	virtual String path() const { return _path; }
 
-	virtual FSList listDir(ListMode) const;
+	virtual AbstractFSList listDir(ListMode) const;
 	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *child(const String &name) const;
 
 private:
 	static char *toAscii(TCHAR *x);
 	static const TCHAR* toUnicode(const char *x);
-	static void addFile (FSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data);
+	static void addFile (AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data);
 };
 
 
@@ -93,7 +93,7 @@
 #endif
 }
 
-void WindowsFilesystemNode::addFile(FSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
+void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
 	WindowsFilesystemNode entry;
 	char *asciiName = toAscii(find_data->cFileName);
 	bool isDirectory;
@@ -117,7 +117,7 @@
 	entry._isValid = true;
 	entry._isPseudoRoot = false;
 
-	list.push_back(wrap(new WindowsFilesystemNode(entry)));
+	list.push_back(new WindowsFilesystemNode(entry));
 }
 
 AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
@@ -163,10 +163,10 @@
 	_isPseudoRoot = false;
 }
 
-FSList WindowsFilesystemNode::listDir(ListMode mode) const {
+AbstractFSList WindowsFilesystemNode::listDir(ListMode mode) const {
 	assert(_isDirectory);
 
-	FSList myList;
+	AbstractFSList myList;
 
 	if (_isPseudoRoot) {
 #ifndef _WIN32_WCE
@@ -186,7 +186,7 @@
 				entry._isValid = true;
 				entry._isPseudoRoot = false;
 				entry._path = toAscii(current_drive);
-				myList.push_back(wrap(new WindowsFilesystemNode(entry)));
+				myList.push_back(new WindowsFilesystemNode(entry));
 		}
 #endif
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list