[Scummvm-cvs-logs] SF.net SVN: scummvm: [26739] scummvm/branches/gsoc2007-fsnode

david_corrales at users.sourceforge.net david_corrales at users.sourceforge.net
Thu May 3 04:39:38 CEST 2007


Revision: 26739
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26739&view=rev
Author:   david_corrales
Date:     2007-05-02 19:39:33 -0700 (Wed, 02 May 2007)

Log Message:
-----------
Use abstract factories to initialize FilesystemNode objects.

Modified Paths:
--------------
    scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/dc/dc-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp_fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/symbian-fs.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/windows/windows-fs.cpp
    scummvm/branches/gsoc2007-fsnode/common/fs.cpp
    scummvm/branches/gsoc2007-fsnode/common/fs.h

Added Paths:
-----------
    scummvm/branches/gsoc2007-fsnode/backends/fs/AbstractFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/FilesystemFactoryMaker.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/SymbianFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/symbian/SymbianFilesystemFactory.h
    scummvm/branches/gsoc2007-fsnode/backends/fs/windows/WindowsFilesystemFactory.cpp
    scummvm/branches/gsoc2007-fsnode/backends/fs/windows/WindowsFilesystemFactory.h

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/AbstractFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/AbstractFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/AbstractFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,48 @@
+#ifndef ABSTRACTFILESYSTEMFACTORY_H_
+#define ABSTRACTFILESYSTEMFACTORY_H_
+
+#include "common/str.h"
+
+/**
+ * Creates concrete FilesystemNode objects depending on the current architecture.
+ */
+class AbstractFilesystemFactory {
+public:
+	typedef Common::String String;
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~AbstractFilesystemFactory() {};
+	
+	/**
+	 * Returns a node representing the "current directory".
+	 * If your system does not support this concept, you can either try to
+	 * emulate it or simply return some "sensible" default directory node,
+	 * e.g. the same value as getRoot() returns.
+	 */
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const = 0;
+	
+	/**
+	 * Construct a node based on a path; the path is in the same format as it
+	 * would be for calls to fopen().
+	 *
+	 * Furthermore getNodeForPath(oldNode.path()) should create a new node
+	 * identical to oldNode. Hence, we can use the "path" value for persistent
+	 * storage e.g. in the config file.
+	 *
+	 * @param path The path string to create a FilesystemNode for.
+	 */
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const = 0;
+	
+	/**
+	 * Returns a special node representing the filesystem root.
+	 * The starting point for any file system browsing.
+	 * 
+	 * On Unix, this will be simply the node for / (the root directory).
+	 * On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
+	 */
+	virtual AbstractFilesystemNode *makeRootFileNode() const = 0;
+};
+
+#endif /*ABSTRACTFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/AbstractFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/FilesystemFactoryMaker.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/FilesystemFactoryMaker.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/FilesystemFactoryMaker.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,113 @@
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/*
+ * All the following includes choose, at compile time, which specific backend will be used
+ * during the execution of the ScummVM.
+ * 
+ * It has to be done this way because not all the necessary libraries will be available in
+ * all build environments. Additionally, this results in smaller binaries.
+ */
+#if defined(__amigaos4__)
+	#include "backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp"
+#endif
+ 
+#if defined(__DC__)
+	#include "backends/fs/dc/RoninCDFilesystemFactory.cpp"
+#endif
+
+#if defined(__DS__)
+	#include "backends/fs/ds/DSFilesystemFactory.cpp"
+#endif
+
+#if defined(__GP32__)
+	#include "backends/fs/gp32/GP32FilesystemFactory.cpp"
+#endif
+
+#if defined(__MORPHOS__)
+	#include "backends/fs/morphos/ABoxFilesystemFactory.cpp"
+#endif
+
+#if defined(PALMOS_MODE)
+	#include "backends/fs/palmos/PalmOSFilesystemFactory.cpp"
+#endif
+
+#if defined(__PLAYSTATION2__)
+	#include "backends/fs/ps2/Ps2FilesystemFactory.cpp"
+#endif
+
+#if defined(__PSP__)
+	#include "backends/fs/psp/PSPFilesystemFactory.cpp"
+#endif
+
+#if defined(__SYMBIAN32__)
+	#include "backends/fs/symbian/SymbianFilesystemFactory.cpp"
+#endif
+
+#if defined(UNIX)
+	#include "backends/fs/posix/POSIXFilesystemFactory.cpp"
+#endif
+
+#if defined(WIN32)
+	#include "backends/fs/windows/WindowsFilesystemFactory.cpp"
+#endif
+
+/**
+ * Creates concrete FilesystemFactory objects depending on the current architecture.
+ */
+class FilesystemFactoryMaker {
+public:
+
+	/**
+	 * Returns the correct concrete factory depending on the current build architecture.
+	 */
+	static AbstractFilesystemFactory *makeFactory();
+	
+protected:
+	FilesystemFactoryMaker() {}; // avoid instances of this class
+};
+
+AbstractFilesystemFactory *FilesystemFactoryMaker::makeFactory(){
+	#if defined(__amigaos4__)
+		return AmigaOSFilesystemFactory::instance();
+	#endif
+	
+	#if defined(__DC__)
+		return RoninCDFilesystemFactory::instance();
+	#endif
+	
+	#if defined(__DS__)
+		return DSFilesystemFactory::instance();
+	#endif
+	
+	#if defined(__GP32__)
+		return GP32FilesystemFactory::instance();
+	#endif
+	
+	#if defined(__MORPHOS__)
+		return ABoxFilesystemFactory::instance();
+	#endif
+	
+	#if defined(PALMOS_MODE)
+		return PalmOSFilesystemFactory::instance();
+	#endif
+	
+	#if defined(__PLAYSTATION2__)
+		return Ps2FilesystemFactory::instance();
+	#endif
+	
+	#if defined(__PSP__)
+		return PSPFilesystemFactory::instance();
+	#endif
+	
+	#if defined(__SYMBIAN32__)
+		return SymbianFilesystemFactory::instance();
+	#endif
+	
+	#if defined(UNIX)
+		return POSIXFilesystemFactory::instance();
+	#endif
+	
+	#if defined(WIN32)
+		return WindowsFilesystemFactory::instance();
+	#endif
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/FilesystemFactoryMaker.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/abstract-fs.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -46,76 +46,73 @@
 	typedef FilesystemNode::ListMode ListMode;
 
 	/**
-	 * The parent node of this directory.
-	 * The parent of the root is the root itself.
-	 */
-	virtual AbstractFilesystemNode *parent() const = 0;
-
-	/**
-	 * The child node with the given name. If no child with this name
+	 * Returns the child node with the given name. If no child with this name
 	 * exists, returns 0. When called on a non-directory node, it should
 	 * handle this gracefully by returning 0.
 	 *
+	 * Example:
+	 * 			Calling getChild() for a node with path "/foo/bar" using name="file.txt",
+	 * 			would produce a new node with "/foo/bar/file.txt" as path.
+	 * 
+	 * @note This function will append a separator char (\ or /) to the end of the
+	 * path if needed.
+	 * 
 	 * @note Handling calls on non-dir nodes gracefully makes it possible to
 	 * switch to a lazy type detection scheme in the future.
+	 * 
+	 * @param name String containing the name of the child to create a new node.
 	 */
-	virtual AbstractFilesystemNode *child(const String &name) const = 0;
+	virtual AbstractFilesystemNode *getChild(const String &name) const = 0;
 
+	/**
+	 * The parent node of this directory.
+	 * The parent of the root is the root itself.
+	 */
+	virtual AbstractFilesystemNode *getParent() const = 0;
 
+public:
 	/**
-	 * 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).
-	 * On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
+	 * Destructor.
 	 */
-	static AbstractFilesystemNode *getRoot();
+	virtual ~AbstractFilesystemNode() {}
 
 	/**
-	 * Returns a node representing the "current directory". If your system does
-	 * not support this concept, you can either try to emulate it or
-	 * simply return some "sensible" default directory node, e.g. the same
-	 * value as getRoot() returns.
+	 * Return a list of child nodes of this directory node. If called on a node
+	 * that does not represent a directory, false is returned.
+	 * 
+	 * @param list List to put the contents of the directory in.
+	 * @param mode Mode to use while listing the directory.
+	 * @return true if succesful, false otherwise (e.g. when the directory does not exist).
 	 */
-	static AbstractFilesystemNode *getCurrentDirectory();
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const = 0;
 
-
 	/**
-	 * Construct a node based on a path; the path is in the same format as it
-	 * would be for calls to fopen().
-	 *
-	 * Furthermore getNodeForPath(oldNode.path()) should create a new node
-	 * identical to oldNode. Hence, we can use the "path" value for persistent
-	 * storage e.g. in the config file.
-	 *
-	 * @todo: This is of course a place where non-portable code easily will sneak
-	 *        in, because the format of the path used here is not well-defined.
-	 *        So we really should reconsider this API and try to come up with
-	 *        something which is more portable but still flexible enough for our
-	 *        purposes.
+	 * Returns a human readable path string.
+	 * 
+	 * @note By default, this method returns the value of getName().
 	 */
-	static AbstractFilesystemNode *getNodeForPath(const String &path);
+	virtual String getDisplayName() const { return getName(); }
 
-
-public:
-	virtual ~AbstractFilesystemNode() {}
-
-	virtual String name() const = 0;
+	/**
+	 * Returns a string with an architecture dependent path description.
+	 */
+	virtual String getName() const = 0;
 	
-	// By default, we use the actual file name as 'display name'.
-	virtual String displayName() const { return name(); }
-
-	virtual bool isValid() const = 0;
-
+	/**
+	 * Returns the 'path' of the current node, usable in fopen().
+	 */
+	virtual String getPath() const = 0;
+	
+	/**
+	 * Indicates whether this path refers to a directory or not.
+	 */
 	virtual bool isDirectory() const = 0;
 	
 	/**
-	 * Return the 'path' of the current node, usable in fopen(). See also
-	 * the static getNodeForPath() method.
+	 * Indicates whether this path is valid or not for usage.
 	 */
-	virtual String path() const = 0;
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const = 0;
+	virtual bool isValid() const = 0;
 
-
 	/* TODO:
 	bool exists();
 
@@ -123,9 +120,8 @@
 	bool isFile();
 
 	bool isReadable();
-	bool isWriteable();
+	bool isWritable();
 	*/
 };
 
-
 #endif

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/amigaos4/AmigaOSFilesystemFactory.h"
+#include "backends/fs/amigaos4/amigaos4-fs.cpp"
+
+AmigaOSFilesystemFactory *AmigaOSFilesystemFactory::_instance = 0;
+
+AmigaOSFilesystemFactory *AmigaOSFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new AmigaOSFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *AmigaOSFilesystemFactory::makeRootFileNode() const {
+	return new AmigaOSFilesystemNode();
+}
+
+AbstractFilesystemNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new AmigaOSFilesystemNode();
+}
+
+AbstractFilesystemNode *AmigaOSFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new AmigaOSFilesystemNode(path);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef AMIGAOSFILESYSTEMFACTORY_H_
+#define AMIGAOSFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates AmigaOSFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class AmigaOSFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of AmigaOSFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of AmigaOSFilesytemFactory.
+	 */
+	static AmigaOSFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~AmigaOSFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	AmigaOSFilesystemFactory() {};
+		
+private:
+	static AmigaOSFilesystemFactory *_instance;
+};
+
+#endif /*AMIGAOSFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/AmigaOSFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/amigaos4/amigaos4-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -1,5 +1,5 @@
 /* ScummVM - Scumm Interpreter
- * Copyright (C) 2005-2006 The ScummVM project, contribution by Hans-J\xF6rg Frieden and Juha Niemim\xE4ki
+ * Copyright (C) 2005-2006 The ScummVM project, contribution by Hans-J�rg Frieden and Juha Niemim�ki
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -35,58 +35,73 @@
 #include <common/stdafx.h>
 
 #include "common/util.h"
-
 #include "engines/engine.h"
 #include "backends/fs/abstract-fs.h"
 
 #define ENTER() /* debug(6, "Enter") */
 #define LEAVE() /* debug(6, "Leave") */
 
-
 const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure?
 
+/**
+ * Implementation of the ScummVM file system API.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
+ */
 class AmigaOSFilesystemNode : public AbstractFilesystemNode {
-	protected:
-		BPTR _pFileLock;
-		String _sDisplayName;
-		bool _bIsDirectory;
-		bool _bIsValid;
-		String _sPath;
+protected:
+	BPTR _pFileLock;
+	String _sDisplayName;
+	String _sPath;
+	bool _bIsDirectory;
+	bool _bIsValid;
 
-	public:
-		AmigaOSFilesystemNode();
-		AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
-		AmigaOSFilesystemNode(const String &p);
+public:
+	/**
+	 * Creates a AmigaOSFilesystemNode with the root node as path.
+	 */
+	AmigaOSFilesystemNode();
+	
+	/**
+	 * Creates a AmigaOSFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
+	AmigaOSFilesystemNode(const String &p);
+	
+	/**
+	 * FIXME: document this constructor.
+	 */
+	AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
 
-	    // Note: Copy constructor is needed because it duplicates the file lock
-		AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
-		
-		virtual ~AmigaOSFilesystemNode();
+    /**
+     * Copy constructor.
+     * 
+     * @note Needed because it duplicates the file lock
+     */
+	AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~AmigaOSFilesystemNode();
 
-		virtual String displayName() const { return _sDisplayName; };
-		virtual String name() const { return _sDisplayName; };
-		virtual bool isValid() const { return _bIsValid; };
-		virtual bool isDirectory() const { return _bIsDirectory; };
-		virtual String path() const { return _sPath; };
-
-		virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-		virtual AbstractFSList listVolumes() const;
-		virtual AbstractFilesystemNode *parent() const;
-		virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual String getDisplayName() const { return _sDisplayName; };
+	virtual String getName() const { return _sDisplayName; };
+	virtual String getPath() const { return _sPath; };
+	virtual bool isValid() const { return _bIsValid; };
+	virtual bool isDirectory() const { return _bIsDirectory; };
+	
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
+	
+	/**
+	 * Creates a list with all the volumes present in the root node.
+	 */
+	virtual AbstractFSList listVolumes() const;
 };
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new AmigaOSFilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String	&path) {
-	return new AmigaOSFilesystemNode(path);
-}
-
 AmigaOSFilesystemNode::AmigaOSFilesystemNode() {
 	ENTER();
 	_sDisplayName = "Available Disks";
@@ -97,7 +112,6 @@
 	LEAVE();
 }
 
-
 AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) {
 	ENTER();
 
@@ -147,7 +161,6 @@
 				const char c = _sPath.lastChar();
 				if (c != '/' && c != ':')
 					_sPath += '/';
-
 			}
 			else {
 				//_bIsDirectory = false;
@@ -167,7 +180,7 @@
 	int bufSize = MAXPATHLEN;
 	_pFileLock = 0;
 
-	while (1) {
+	while (true) {
 		char *n = new char[bufSize];
 		if (IDOS->NameFromLock(pLock, (STRPTR)n, bufSize) != DOSFALSE) {
 			_sPath = n;
@@ -183,6 +196,7 @@
 			delete [] n;
 			return;
 		}
+		
 		bufSize *= 2;
 		delete [] n;
 	}
@@ -235,7 +249,31 @@
 	LEAVE();
 }
 
-bool AmigaOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+AbstractFilesystemNode *AmigaOSFilesystemNode::getChild(const String &n) const {
+	if (!_bIsDirectory) {
+		debug(6, "Not a directory");
+		return 0;
+	}
+
+	String newPath(_sPath);
+
+	if (_sPath.lastChar() != '/')
+		newPath += '/';
+
+	newPath += n;
+	BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK);
+
+	if (!lock) {
+		debug(6, "Bad path");
+		return 0;
+	}
+
+	IDOS->UnLock(lock);
+
+	return new AmigaOSFilesystemNode(newPath);
+}
+
+bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
 	ENTER();
 
 	if (!_bIsValid) {
@@ -305,10 +343,11 @@
 	}
 
 	LEAVE();
+	
 	return true;
 }
 
-AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const {
+AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const {
 	ENTER();
 
 	if (!_bIsDirectory) {
@@ -334,35 +373,10 @@
 		node = new AmigaOSFilesystemNode();
 
 	LEAVE();
+	
 	return node;
 }
 
-AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &n) const {
-	
-	if (!_bIsDirectory) {
-		debug(6, "Not a directory");
-		return 0;
-	}
-
-	String newPath(_sPath);
-
-	if (_sPath.lastChar() != '/')
-		newPath += '/';
-
-	newPath += n;
-
-	BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK);
-
-	if (!lock) {
-		debug(6, "Bad path");
-		return 0;
-	}
-
-	IDOS->UnLock(lock);
-
-	return new AmigaOSFilesystemNode(newPath);
-}
-
 AbstractFSList AmigaOSFilesystemNode::listVolumes()	const {
 	ENTER();
 
@@ -428,7 +442,8 @@
 	IDOS->UnLockDosList(kLockFlags);
 
 	LEAVE();
+	
 	return myList;
 }
 
-#endif
+#endif //defined(__amigaos4__)

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/dc/RoninCDFilesystemFactory.h"
+#include "backends/fs/dc/dc-fs.cpp"
+
+RoninCDFilesystemFactory *RoninCDFilesystemFactory::_instance = 0;
+
+RoninCDFilesystemFactory *RoninCDFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new RoninCDFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *RoninCDFilesystemFactory::makeRootFileNode() const {
+	return new RoninCDFilesystemNode();
+}
+
+AbstractFilesystemNode *RoninCDFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new RoninCDFilesystemNode();
+}
+
+AbstractFilesystemNode *RoninCDFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new RoninCDFilesystemNode(path, true);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef RONINCDFILESYSTEMFACTORY_H_
+#define RONINCDFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates RoninCDFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class RoninCDFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of RoninCDFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of RoninCDFilesytemFactory.
+	 */
+	static RoninCDFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~RoninCDFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	RoninCDFilesystemFactory() {};
+		
+private:
+	static RoninCDFilesystemFactory *_instance;
+};
+
+#endif /*RONINCDFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/RoninCDFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/dc/dc-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/dc/dc-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/dc/dc-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -22,40 +22,59 @@
 #if defined(__DC__)
 
 #include "common/stdafx.h"
-
 #include "backends/fs/abstract-fs.h"
 
 #include <ronin/cdfs.h>
 #include <stdio.h>
 #include <unistd.h>
 
-/*
- * Implementation of the ScummVM file system API based on ronin.
+/**
+ * Implementation of the ScummVM file system API based on POSIX.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
-
 class RoninCDFilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
-	String _path;
 
 public:
+	/**
+	 * Creates a RoninCDFilesystemNode with the root node as path.
+	 */
 	RoninCDFilesystemNode();
+	
+	/**
+	 * Creates a RoninCDFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 * @param verify true if the isValid and isDirectory flags should be verified during the construction.
+	 */
 	RoninCDFilesystemNode(const String &path, bool verify);
 
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
 };
 
-
+/**
+ * Returns the last component of a given path.
+ * 
+ * Examples:
+ * 			/foo/bar.txt would return /bar.txt
+ * 			/foo/bar/    would return /bar/
+ *  
+ * @param str String containing the path.
+ * @return Pointer to the first char of the last component inside str.
+ */
 static const char *lastPathComponent(const Common::String &str) {
 	const char *start = str.c_str();
 	const char *cur = start + str.size() - 2;
@@ -67,22 +86,6 @@
 	return cur + 1;
 }
 
-
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	// Since there is no way to _set_ the current directory,
-	// it will always be /...
-
-	return getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new RoninCDFilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new RoninCDFilesystemNode(path, true);
-}
-
 RoninCDFilesystemNode::RoninCDFilesystemNode() {
 	// The root dir.
 	_path = "/";
@@ -115,10 +118,23 @@
 	}
 }
 
-bool RoninCDFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+AbstractFilesystemNode *RoninCDFilesystemNode::getChild(const String &n) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
 	assert(_isDirectory);
+	
+	String newPath(_path);
+	if (_path.lastChar() != '/')
+		newPath += '/';
+	newPath += n;
+
+	return new RoninCDFilesystemNode(newPath, true);
+}
+
+bool RoninCDFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
+	assert(_isDirectory);
+	
 	DIR *dirp = opendir(_path.c_str());
-
 	struct dirent *dp;
 
 	if (dirp == NULL)
@@ -147,35 +163,22 @@
 
 		if (entry._isDirectory)
 			entry._path += "/";
+			
 		myList.push_back(new RoninCDFilesystemNode(entry));
 	}
 	closedir(dirp);
+	
 	return true;
 }
 
-AbstractFilesystemNode *RoninCDFilesystemNode::parent() const {
+AbstractFilesystemNode *RoninCDFilesystemNode::getParent() const {
 	if (_path == "/")
 		return 0;
 
 	const char *start = _path.c_str();
 	const char *end = lastPathComponent(_path);
 
-	RoninCDFilesystemNode *p = new RoninCDFilesystemNode(String(start, end - start), false);
-
-	return p;
+	return new RoninCDFilesystemNode(String(start, end - start), false);
 }
 
-AbstractFilesystemNode *RoninCDFilesystemNode::child(const String &n) const {
-	// FIXME: Pretty lame implementation! We do no error checking to speak
-	// of, do not check if this is a special node, etc.
-	assert(_isDirectory);
-	String newPath(_path);
-	if (_path.lastChar() != '/')
-		newPath += '/';
-	newPath += n;
-	RoninCDFilesystemNode *p = new RoninCDFilesystemNode(newPath, true);
-
-	return p;
-}
-
 #endif // defined(__DC__)

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,36 @@
+#include "backends/fs/ds/DSFilesystemFactory.h"
+#include "backends/fs/ds/ds-fs.cpp"
+#include "dsmain.h" //for the isGBAMPAvailable() function
+
+DSFilesystemFactory *DSFilesystemFactory::_instance = 0;
+
+DSFilesystemFactory *DSFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new DSFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const {
+	if (DS::isGBAMPAvailable()) {
+		return new DS::GBAMPFileSystemNode();
+	} else {
+		return new DS::DSFileSystemNode();
+	}
+}
+
+AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	if (DS::isGBAMPAvailable()) {
+		return new DS::GBAMPFileSystemNode();
+	} else {
+		return new DS::DSFileSystemNode();
+	}
+}
+
+AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const String &path) const {
+	if (DS::isGBAMPAvailable()) {
+		return new DS::GBAMPFileSystemNode(path);
+	} else {
+		return new DS::DSFileSystemNode(path);
+	}
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef DSFILESYSTEMFACTORY_H_
+#define DSFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates DSFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class DSFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of DSFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of DSFilesytemFactory.
+	 */
+	static DSFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~DSFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	DSFilesystemFactory() {};
+		
+private:
+	static DSFilesystemFactory *_instance;
+};
+
+#endif /*DSFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/DSFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -17,7 +17,6 @@
  *
  */
 
-
 #include "stdafx.h"
 #include "str.h"
 #include "fs.h"
@@ -27,14 +26,10 @@
 #include "dsmain.h"
 #include "gba_nds_fat.h"
 
-
 namespace DS {
 
-
-
-
 //////////////////////////////////////////////////////////////
-// DSFileSystemNode - Flash ROM file system using Zip files
+// DSFileSystemNode - Flash ROM file system using Zip files //
 //////////////////////////////////////////////////////////////
 
 ZipFile*   	DSFileSystemNode::_zipFile = NULL;
@@ -63,7 +58,6 @@
 	char disp[128];
 	char* pathStr = (char *) path.c_str();
 	
-	
 	int lastSlash = 3;
 	for (int r = 0; r < (int) strlen(pathStr) - 1; r++) {
 		if (path[r] == '\\') {
@@ -78,13 +72,10 @@
 //	_isValid = true;
 //	_isDirectory = false;
 
-
-
 	if (!strncmp(pathStr, "ds:/", 4)) {
 		pathStr += 4;
 	}
 	
-
 	if (*pathStr == '\0') {
 		_isValid = true;
 		_isDirectory = true;
@@ -127,35 +118,10 @@
 }
 
 DSFileSystemNode::DSFileSystemNode(const DSFileSystemNode* node) {
-
+	//TODO: not implemented?
 }
 
-AbstractFilesystemNode* DSFileSystemNode::parent() const {
-//	consolePrintf("parent\n");
-	DSFileSystemNode *p;
-
-	if (_path != "ds:/") {  
-		char *path = (char *) _path.c_str();
-		int lastSlash = 4;
-		
-		for (int r = 4; r < (int) strlen((char *) path); r++) {
-			if (path[r] == '\\') {
-				lastSlash = r;
-			}
-		}
-
-		p = new DSFileSystemNode(String(path, lastSlash));
-		((DSFileSystemNode *) (p))->_isDirectory = true;
-	} else {
-		p = new DSFileSystemNode();
-	}
-
-	return p;
-
-}
-
-
-AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& n) const {
+AbstractFilesystemNode *DSFileSystemNode::getChild(const Common::String& n) const {
 	if (_path.lastChar() == '\\') {
 		return new DSFileSystemNode(_path + n);
 	} else {
@@ -165,14 +131,10 @@
 	return NULL;
 }
 
-
-bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const {
+bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode) const {
 //	consolePrintf("Listdir\n");
-
-	
 //	consolePrintf("Directory\n");
 
-	
 	char temp[128];
 	strcpy(temp, _path.c_str());
 
@@ -187,14 +149,13 @@
 /*			// This is the root dir, so add the RAM folder
 			DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/ram");
 			dsfsn->_isDirectory = true;
-			dirList->push_back(wrap(dsfsn));*/
+			dirList->push_back(wrap(dsfsn));
+*/
 		}
 	} else {
 		_zipFile->changeDirectory(temp);
 	}
 	
-	
-	
 	if (_zipFile->restartFile()) {
 		do {
 			char n[128];	
@@ -215,13 +176,33 @@
 	return true;
 }
 
+AbstractFilesystemNode* DSFileSystemNode::getParent() const {
+//	consolePrintf("parent\n");
+	DSFileSystemNode *p;
 
+	if (_path != "ds:/") {  
+		char *path = (char *) _path.c_str();
+		int lastSlash = 4;
+		
+		for (int r = 4; r < (int) strlen((char *) path); r++) {
+			if (path[r] == '\\') {
+				lastSlash = r;
+			}
+		}
 
+		p = new DSFileSystemNode(String(path, lastSlash));
+		((DSFileSystemNode *) (p))->_isDirectory = true;
+	} else {
+		p = new DSFileSystemNode();
+	}
 
-/////////////////////////////////////////////////////////////////////////
-// GBAMPFileSystemNode - File system using GBA Movie Player and CF card
-/////////////////////////////////////////////////////////////////////////
+	return p;
+}
 
+//////////////////////////////////////////////////////////////////////////
+// GBAMPFileSystemNode - File system using GBA Movie Player and CF card //
+//////////////////////////////////////////////////////////////////////////
+
 GBAMPFileSystemNode::GBAMPFileSystemNode() {
 	_displayName = "mp:/";
 	_path = "mp:/";
@@ -287,35 +268,10 @@
 
 
 GBAMPFileSystemNode::GBAMPFileSystemNode(const GBAMPFileSystemNode* node) {
-
+	//TODO: not implemented?
 }
 
-
-AbstractFilesystemNode* GBAMPFileSystemNode::parent() const {
-//	consolePrintf("parent\n");
-	GBAMPFileSystemNode *p;
-
-	if (_path != "mp:/") {  
-		char *path = (char *) _path.c_str();
-		int lastSlash = 4;
-		
-		for (int r = 4; r < (int) strlen((char *) path); r++) {
-			if (path[r] == '/') {
-				lastSlash = r;
-			}
-		}
-
-		p = new GBAMPFileSystemNode(String(path, lastSlash));
-		p->_isDirectory = true;
-	} else {
-		p = new GBAMPFileSystemNode();
-	}
-
-	return p;
-
-}
-
-AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& n) const {
+AbstractFilesystemNode *GBAMPFileSystemNode::getChild(const Common::String& n) const {
 	if (_path.lastChar() == '\\') {
 		return new DSFileSystemNode(_path + n);
 	} else {
@@ -325,7 +281,7 @@
 	return NULL;
 }
 
-bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const {
+bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode) const {
 //	consolePrintf("Listdir\n");
 
 	enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 };
@@ -343,7 +299,6 @@
 		pathTemp++;
 	}
 
-
 //	consolePrintf("This dir: %s\n", path);
 	FAT_chdir(path);
 	
@@ -366,8 +321,6 @@
 //				dsfsn->_isDirectory = entryType == DIR;
 				dirList.push_back((dsfsn));
 			}
-		
-		
 		} else {
 //			consolePrintf("Skipping %s\n", fname);
 		}
@@ -382,7 +335,29 @@
 	return true;
 }
 
+AbstractFilesystemNode* GBAMPFileSystemNode::getParent() const {
+//	consolePrintf("parent\n");
+	GBAMPFileSystemNode *p;
 
+	if (_path != "mp:/") {  
+		char *path = (char *) _path.c_str();
+		int lastSlash = 4;
+		
+		for (int r = 4; r < (int) strlen((char *) path); r++) {
+			if (path[r] == '/') {
+				lastSlash = r;
+			}
+		}
+
+		p = new GBAMPFileSystemNode(String(path, lastSlash));
+		p->_isDirectory = true;
+	} else {
+		p = new GBAMPFileSystemNode();
+	}
+
+	return p;
+}
+
 // Stdio replacements
 #define MAX_FILE_HANDLES 32
 
@@ -390,9 +365,6 @@
 DS::fileHandle handle[MAX_FILE_HANDLES];
 
 FILE* std_fopen(const char* name, const char* mode) {
-
-	
-
 	if (!inited) {
 		for (int r = 0; r < MAX_FILE_HANDLES; r++) {
 			handle[r].used = false;
@@ -400,17 +372,14 @@
 		inited = true;
 		currentDir[0] = '\0';
 	}
-
-
 	
-	
 	char* realName = (char *) name;
 	
 	// Remove file system prefix
 	if ((name[0] == 'd') && (name[1] == 's') && (name[2] == ':') && (name[3] == '/')) {
 		realName += 4;
 	}
-
+	
 	if ((name[0] == 'm') && (name[1] == 'p') && (name[2] == ':') && (name[3] == '/')) {
 		realName += 4;
 	}
@@ -418,7 +387,6 @@
 //	consolePrintf("Open file:");
 //	consolePrintf("'%s', [%s]", realName, mode);
 
-
 	if (DS::isGBAMPAvailable()) {
 		FAT_chdir("/");
 		
@@ -440,10 +408,9 @@
 		
 		return (FILE *) result;
 	}
-
 	
 	// Fail to open file for writing.  It's in ROM!
-
+	
 	// Allocate a file handle
 	int r = 0;
 	while (handle[r].used) r++;
@@ -456,7 +423,6 @@
 		handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, false);
 	}
 
-	
 	if (handle[r].sramFile) {
 		handle[r].used = true;
 		handle[r].pos = 0;
@@ -510,6 +476,7 @@
 		return NULL;
 	}
 }
+
 void std_fclose(FILE* handle) {
 
 	if (DS::isGBAMPAvailable()) {
@@ -525,14 +492,9 @@
 }
 
 size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
-
 //	consolePrintf("fread %d,%d %d ", size, numItems, ptr);
-	
-	
 
 	if (DS::isGBAMPAvailable()) {
-	
-		
 		int bytes = FAT_fread((void *) ptr, size, numItems, (FAT_FILE *) handle);
 		if (!std_feof(handle)) {
 			return numItems;
@@ -557,27 +519,24 @@
 		
 		}
 		
-		return item;*/
-
-
+		return item;
+*/
 		int items = 0;
 	
 		//for (int r = 0; r < numItems; r++) {
 			if (!std_feof(handle)) {
-				
-
-				
 /*				for (int t = 0; t < size; t++) {
 					if (feof(handle)) eof = true;
 					*(((char *) (ptr)) + r * size + t) = getc(handle);
 				}*/
 				int left = size * numItems;
 				int bytesRead = -1;
+				
 				while ((left > 0) && (!FAT_feof((FAT_FILE *) handle))) {
 					int amount = left > 8192? 8192: left;
 //					do {
 						bytesRead = FAT_fread((void *) ptr, 1, amount, (FAT_FILE *) handle);
-	/*					if (bytesRead == 0) {
+/*						if (bytesRead == 0) {
 							consolePrintf("Pos:%d items:%d num:%d amount:%d read:%d\n", ftell(handle), items, numItems, amount, bytesRead);
 							left++;
 							
@@ -589,27 +548,24 @@
 							fread(ptr, 1024, 1, handle);
 							swiWaitForVBlank();
 							//while (true);
-						}*/
-					//} while (bytesRead == 0);
+						}
+
+					} while (bytesRead == 0);
+*/
 					left -= bytesRead;
 					ptr = ((char *) (ptr)) + bytesRead;				
 				}
 				
 				items = numItems - (left / size);
-				
-			
-		
-				
+
 //				FAT_fread((void *) ptr, size, 1, ((int) (handle)) - 1);
-	//			ptr = ((char *) (ptr)) + size;
-				
+//				ptr = ((char *) (ptr)) + size;	
 			}
-		//}
+//		}
 		
 //		consolePrintf("...done %d \n", items)
 
 		return items;
-		
 	}
 	
 	if (handle->sramFile) {
@@ -627,7 +583,6 @@
 		return bytes / size;
 	}
 
-
 	if (handle->pos + size * numItems > handle->size) {
 		numItems = (handle->size - handle->pos) / size;
 		if (numItems < 0) numItems = 0;
@@ -636,10 +591,8 @@
 //	consolePrintf("read %d  ", size * numItems);
 
 	memcpy((void *) ptr, handle->data + handle->pos, size * numItems);
-
 	handle->pos += size * numItems;
 
-	
 	return numItems;
 }
 
@@ -654,7 +607,6 @@
 	//consolePrintf("fwrite size=%d\n", size * numItems);
 
 	if (DS::isGBAMPAvailable()) {
-
 		FAT_fwrite(((char *) (ptr)), size, numItems, (FAT_FILE *) handle);
 		return numItems;
 		
@@ -672,7 +624,6 @@
 		return numItems;
 	}
 
-
 	if (handle->sramFile) {
 		handle->sramFile->write(ptr, size);
 		return size;
@@ -701,6 +652,7 @@
 }
 
 void std_fflush(FILE* handle) {
+	//FIXME: not implemented?
 //	consolePrintf("fflush ");
 }
 
@@ -708,7 +660,6 @@
 //	consolePrintf("fgets file=%d ", file);
 	
 	if (DS::isGBAMPAvailable()) {
-		
 		char* s = str;
 		while ((*s++ = std_getc(file)) >= 32) {
 //			consolePrintf("%d ", *s);
@@ -720,7 +671,6 @@
 		return str;
 	}
 	
-	
 	if (file->sramFile) {
 		file->pos--;
 		int p = -1;
@@ -740,7 +690,6 @@
 }
 
 long int std_ftell(FILE* handle) {
-
 	if (DS::isGBAMPAvailable()) {
 		return FAT_ftell((FAT_FILE *) handle);
 	}
@@ -755,39 +704,30 @@
 		return FAT_fseek((FAT_FILE *) handle, offset, whence);
 	}
 
-
 	switch (whence) {
-		case SEEK_CUR: {
+		case SEEK_CUR:
 			handle->pos += offset;
 			break;
-		}
-		
-		case SEEK_SET: {
+		case SEEK_SET:
 			handle->pos = offset;
 			break;
-		}
-		
-		case SEEK_END: {
+		case SEEK_END:
 			handle->pos = handle->size + offset;
 			break;
-		}
-		
-		default: {
+		default:
 			handle->pos = offset;
 			break;
-		}
-		
 	}
 	
 	return 0;
 }
 
 void std_clearerr(FILE* handle) {
+	//FIXME: not implemented?
 //	consolePrintf("clearerr ");
 }
 
 int std_getc(FILE* handle) {
-
 	if (DS::isGBAMPAvailable()) {
 		char c;
 		FAT_fread(&c, 1, 1, (FAT_FILE *) handle);
@@ -849,24 +789,3 @@
 }
 
 } // namespace DS
-
-// These functions are added to AbstractFileSystemNode and are therefore outside
-// the DS namespace.
-
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-//	consolePrintf("New node");
-        
-	if (DS::isGBAMPAvailable()) {
-		return new DS::GBAMPFileSystemNode();
-	} else {
-		return new DS::DSFileSystemNode();
-	}
-}
-
-AbstractFilesystemNode* AbstractFilesystemNode::getNodeForPath(const String& path) {
-	if (DS::isGBAMPAvailable()) {
-		return new DS::GBAMPFileSystemNode(path);
-	} else {
-		return new DS::DSFileSystemNode(path);
-	}
-}

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.h	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ds/ds-fs.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -20,8 +20,6 @@
 #ifndef _DS_FS_H
 #define _DS_FS_H
 
-
-
 //#include <NDS/ARM9/console.h>
 #include "fs.h"
 #include "zipreader.h"
@@ -29,81 +27,131 @@
 #include "scummconsole.h"
 #include "gba_nds_fat.h"
 #include "backends/fs/abstract-fs.h"
-//#include "backends/fs/fs.h"
 
 namespace DS {
 
 /**
+ * Implementation of the ScummVM file system API.
  * This class is used when a Flash cart is in use.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
 class DSFileSystemNode : public AbstractFilesystemNode {
 protected:
+	typedef class Common::String String;
+
 	static ZipFile* _zipFile;
 
-	typedef class Common::String String;
-
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
-	String _path;
 	int _refCountVal;
 	
 public:
+	/**
+	 * Creates a DSFilesystemNode with the root node as path.
+	 */
 	DSFileSystemNode();
+	
+	/**
+	 * Creates a DSFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
 	DSFileSystemNode(const String &path);
-	DSFileSystemNode(const DSFileSystemNode *node);
+	
+	/**
+	 * Creates a DSFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 * @param path true if path is a directory, false otherwise.
+	 */
 	DSFileSystemNode(const String& path, bool isDir);
 	
-	virtual String displayName() const {  return _displayName; }
-	virtual String name() const {  return _displayName; }
+	/**
+	 * Copy constructor.
+	 */
+	DSFileSystemNode(const DSFileSystemNode *node);
+	
+	virtual String getDisplayName() const {  return _displayName; }
+	virtual String getName() const {  return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 	
-	virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
-	virtual AbstractFilesystemNode *parent() const;
+	/**
+	 * Returns a copy of this node.
+	 */
 	virtual AbstractFilesystemNode *clone() const { return new DSFileSystemNode(this); }
-	virtual AbstractFilesystemNode *child(const Common::String& name) const;
+	virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
+	virtual AbstractFilesystemNode *getParent() const;
+	
+	/**
+	 * Returns the zip file this node points to.
+	 * TODO: check this documentation.
+	 */
 	static ZipFile* getZip() { return _zipFile; }
 };
 
-
-/**
+ /**
+ * Implementation of the ScummVM file system API.
  * This class is used when the GBAMP (GBA Movie Player) is used with a CompactFlash card.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
 class GBAMPFileSystemNode : public AbstractFilesystemNode {
 protected:
 	typedef class Common::String String;
 
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
-	String _path;
-	
 	int _refCountVal;
 	
 public:
+	/**
+	 * Creates a GBAMPFilesystemNode with the root node as path.
+	 */
 	GBAMPFileSystemNode();
+	
+	/**
+	 * Creates a GBAMPFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
 	GBAMPFileSystemNode(const String &path);
+	
+	/**
+	 * Creates a DSFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 * @param path true if path is a directory, false otherwise.
+	 */
 	GBAMPFileSystemNode(const String &path, bool isDirectory);
+	
+	/**
+	 * Copy constructor.
+	 */
 	GBAMPFileSystemNode(const GBAMPFileSystemNode *node);
 
-	virtual String displayName() const {  return _displayName; }
-	virtual String name() const {  return _displayName; }
+	virtual String getDisplayName() const {  return _displayName; }
+	virtual String getName() const {  return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
+	virtual bool isValid() const { return _isValid; }
 	
-	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
-	virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
-	virtual AbstractFilesystemNode *parent() const;
+	/**
+	 * Returns a copy of this node.
+	 */
 	virtual AbstractFilesystemNode *clone() const { return new GBAMPFileSystemNode(this); }
-	virtual AbstractFilesystemNode *child(const Common::String& name) const;
-	
+	virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
+	virtual AbstractFilesystemNode *getParent() const;
 };
 
-
-
-
 struct fileHandle {
 	int pos;
 	bool used;
@@ -113,7 +161,6 @@
 	DSSaveFile* sramFile;
 };
 
-
 #undef stderr
 #undef stdout
 #undef stdin
@@ -137,6 +184,6 @@
 void 	std_cwd(char* dir);
 void 	std_fflush(FILE* handle);
 
-}
+} //namespace DS
 
-#endif
+#endif //_DS_FS_H

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/gp32/GP32FilesystemFactory.h"
+#include "backends/fs/gp32/gp32-fs.cpp"
+
+GP32FilesystemFactory *GP32FilesystemFactory::_instance = 0;
+
+GP32FilesystemFactory *GP32FilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new GP32FilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *GP32FilesystemFactory::makeRootFileNode() const {
+	return new GP32FilesystemNode();
+}
+
+AbstractFilesystemNode *GP32FilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new GP32FilesystemNode();
+}
+
+AbstractFilesystemNode *GP32FilesystemFactory::makeFileNodePath(const String &path) const {
+	return new GP32FilesystemNode(path);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef GP32FILESYSTEMFACTORY_H_
+#define GP32FILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates GP32FilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class GP32FilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of GP32FilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of GP32FilesytemFactory.
+	 */
+	static GP32FilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~GP32FilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	GP32FilesystemFactory() {};
+		
+private:
+	static GP32FilesystemFactory *_instance;
+};
+
+#endif /*GP32FILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/GP32FilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/gp32/gp32-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -24,38 +24,78 @@
  */
 
 #include "stdafx.h"
-
 #include "backends/fs/abstract-fs.h"
 
+#define MAX_PATH_SIZE 256
+
+/**
+ * Implementation of the ScummVM file system API.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
+ */
 class GP32FilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isRoot;
-	String _path;
 
 public:
+	/**
+	 * Creates a GP32FilesystemNode with the root node as path.
+	 */
 	GP32FilesystemNode();
+	
+	/**
+	 * Creates a GP32FilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
 	GP32FilesystemNode(const String &path);
 
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	// FIXME: isValid should return false if this Node can't be used!
-	// client code can rely on the return value.
+	// so client code can rely on the return value.
 	virtual bool isValid() const { return true; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
 };
 
-#define MAX_PATH_SIZE 256
-
 const char gpRootPath[] = "gp:\\";
 //char gpCurrentPath[MAX_PATH_SIZE] = "gp:\\";		// must end with '\'
 
+/**
+ * Returns the last component of a given path.
+ * 
+ * Examples:
+ * 			gp:\foo\bar.txt would return "\bar.txt"
+ * 			gp:\foo\bar\    would return "\bar\"
+ *  
+ * @param str Path to obtain the last component from.
+ * @return Pointer to the first char of the last component inside str.
+ */
+static const char *lastPathComponent(const Common::String &str) {
+	const char *start = str.c_str();
+	const char *cur = start + str.size() - 2;
+
+	while (cur >= start && *cur != '\\') {
+		--cur;
+	}
+
+	return cur + 1;
+}
+
+/**
+ * FIXME: document this function.
+ * 
+ * @param path
+ * @param convPath
+ */
 int gpMakePath(const char *path, char *convPath) {
 	// copy root or current directory
 	const char *p;
@@ -106,18 +146,6 @@
 	return 0;
 }
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new GP32FilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new GP32FilesystemNode(path);
-}
-
 GP32FilesystemNode::GP32FilesystemNode() {
 	_isDirectory = true;
 	_isRoot = true;
@@ -132,8 +160,8 @@
 	gpMakePath(path.c_str(), convPath);
 
 	_path = convPath;
-
 	pos = convPath;
+	
 	while (*pos)
 		if (*pos++ == '\\')
 			dsplName = pos;
@@ -150,14 +178,25 @@
 	_isDirectory = true;
 }
 
-bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+AbstractFilesystemNode *GP32FilesystemNode::getChild(const String &n) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
 	assert(_isDirectory);
+	
+	String newPath(_path);
+	if (_path.lastChar() != '\\')
+		newPath += '\\';
+	newPath += n;
 
+	return new GP32FilesystemNode(newPath);
+}
+
+bool GP32FilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
+	assert(_isDirectory);
+
 	GPDIRENTRY dirEntry;
 	GPFILEATTR attr;
-
 	GP32FilesystemNode entry;
-
 	uint32 read;
 
 	if (mode == FilesystemNode::kListAll)
@@ -168,9 +207,11 @@
 	int startIdx = 0; // current file
 	String listDir(_path);
 	//listDir += "/";
+	
 	while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read)  == SM_OK) {
 		if (dirEntry.name[0] == '.')
 			continue;
+			
 		entry._displayName = dirEntry.name;
 		entry._path = _path;
 		entry._path += dirEntry.name;
@@ -194,18 +235,7 @@
 	return true;
 }
 
-static const char *lastPathComponent(const Common::String &str) {
-	const char *start = str.c_str();
-	const char *cur = start + str.size() - 2;
-
-	while (cur >= start && *cur != '\\') {
-		--cur;
-	}
-
-	return cur + 1;
-}
-
-AbstractFilesystemNode *GP32FilesystemNode::parent() const {
+AbstractFilesystemNode *GP32FilesystemNode::getParent() const {
 	if(_isRoot)
 		return 0;
 
@@ -218,16 +248,3 @@
 
 	return p;
 }
-
-AbstractFilesystemNode *GP32FilesystemNode::child(const String &n) const {
-	// FIXME: Pretty lame implementation! We do no error checking to speak
-	// of, do not check if this is a special node, etc.
-	assert(_isDirectory);
-	String newPath(_path);
-	if (_path.lastChar() != '\\')
-		newPath += '\\';
-	newPath += n;
-	GP32FilesystemNode *p = new GP32FilesystemNode(newPath);
-
-	return p;
-}

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/morphos/ABoxFilesystemFactory.h"
+#include "backends/fs/morphos/abox-fs.cpp"
+
+ABoxFilesystemFactory *ABoxFilesystemFactory::_instance = 0;
+
+ABoxFilesystemFactory *ABoxFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new ABoxFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *ABoxFilesystemFactory::makeRootFileNode() const {
+	return new ABoxFilesystemNode();
+}
+
+AbstractFilesystemNode *ABoxFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new ABoxFilesystemNode();
+}
+
+AbstractFilesystemNode *ABoxFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new ABoxFilesystemNode(path);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef ABOXFILESYSTEMFACTORY_H_
+#define ABOXFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates ABoxFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class ABoxFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of ABoxFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of ABoxFilesytemFactory.
+	 */
+	static ABoxFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~ABoxFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	ABoxFilesystemFactory() {};
+		
+private:
+	static ABoxFilesystemFactory *_instance;
+};
+
+#endif /*ABOXFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/ABoxFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/morphos/abox-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -32,52 +32,63 @@
 #include "base/engine.h"
 #include "backends/fs/abstract-fs.h"
 
-/*
+/**
  * Implementation of the ScummVM file system API based on the MorphOS A-Box API.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
-
 class ABoxFilesystemNode : public AbstractFilesystemNode {
-	protected:
-		BPTR _lock;
-		String _displayName;
-		bool _isDirectory;
-		bool _isValid;
-		String _path;
+protected:
+	BPTR _lock;
+	String _displayName;
+	String _path;
+	bool _isDirectory;
+	bool _isValid;
 
-	public:
-		ABoxFilesystemNode();
-		ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name = NULL);
-		ABoxFilesystemNode(const String &p);
-		ABoxFilesystemNode(const ABoxFilesystemNode &node);
+public:
+	/**
+	 * Creates a ABoxFilesystemNode with the root node as path.
+	 */
+	ABoxFilesystemNode();
+	
+	/**
+	 * Creates a ABoxFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
+	ABoxFilesystemNode(const String &p);
+	
+	/**
+	 * FIXME: document this constructor.
+	 */
+	ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name = NULL);
+	
+	/**
+	 * Copy constructor.
+	 */
+	ABoxFilesystemNode(const ABoxFilesystemNode &node);
 
-		~ABoxFilesystemNode();
+	/**
+	 * Destructor.
+	 */
+	~ABoxFilesystemNode();
 
-		virtual String displayName() const { return _displayName; }
-		virtual String name() const { return _displayName; };
-		virtual bool isValid() const { return _isValid; }
-		virtual bool isDirectory() const { return _isDirectory; }
-		virtual String path() const { return _path; }
-
-		virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-		static  AbstractFSList listRoot();
-		virtual AbstractFilesystemNode *parent() const;
-		virtual AbstractFilesystemNode *child(const String &name) const;
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; };
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
+	virtual bool isValid() const { return _isValid; }
+	
+	virtual AbstractFilesystemNode *getChild(const String &name) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
+	
+	/**
+	 * Return the list of child nodes for the root node.
+	 */
+	static AbstractFSList getRootChildren();
 };
 
-
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String	&path) {
-	return new ABoxFilesystemNode(path);
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot()
-{
-	return new ABoxFilesystemNode();
-}
-
 ABoxFilesystemNode::ABoxFilesystemNode()
 {
 	_displayName = "Mounted Volumes";
@@ -87,57 +98,6 @@
 	_lock = NULL;
 }
 
-ABoxFilesystemNode::ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name)
-{
-	int bufsize = 256;
-
-	_lock = NULL;
-	for (;;)
-	{
-		char name[bufsize];
-		if (NameFromLock(lock, name, bufsize) != DOSFALSE)
-		{
-			_path = name;
-			_displayName = display_name ? display_name : FilePart(name);
-			break;
-		}
-		if (IoErr() != ERROR_LINE_TOO_LONG)
-		{
-			_isValid = false;
-			debug(6, "Error while retrieving path name: %ld", IoErr());
-			return;
-		}
-		bufsize *= 2;
-	}
-
-	_isDirectory = false;
-	_isValid = false;
-
-	FileInfoBlock *fib = (FileInfoBlock*) AllocDosObject(DOS_FIB, NULL);
-	if (fib == NULL)
-	{
-		debug(6, "Failed to allocate memory for FileInfoBlock");
-		return;
-	}
-
-	if (Examine(lock, fib) != DOSFALSE)
-	{
-		_isDirectory = fib->fib_EntryType > 0;
-		if (_isDirectory)
-		{
-			if (fib->fib_EntryType != ST_ROOT)
-				_path += "/";
-			_lock = DupLock(lock);
-			_isValid = (_lock != NULL);
-		}
-		else
-		{
-			_isValid = true;
-		}
-	}
-	FreeDosObject(DOS_FIB, fib);
-}
-
 ABoxFilesystemNode::ABoxFilesystemNode(const String &p) {
 	int len = 0, offset = p.size();
 
@@ -165,7 +125,6 @@
 	}
 
 	// Check whether the node exists and if it is a directory
-
 	BPTR pLock = Lock((STRPTR)_path.c_str(), SHARED_LOCK);
 	if (pLock)
 	{
@@ -195,6 +154,58 @@
 	FreeDosObject(DOS_FIB, fib);
 }
 
+ABoxFilesystemNode::ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name)
+{
+	int bufsize = 256;
+
+	_lock = NULL;
+	for (;;)
+	{
+		char name[bufsize];
+		if (NameFromLock(lock, name, bufsize) != DOSFALSE)
+		{
+			_path = name;
+			_displayName = display_name ? display_name : FilePart(name);
+			break;
+		}
+		if (IoErr() != ERROR_LINE_TOO_LONG)
+		{
+			_isValid = false;
+			debug(6, "Error while retrieving path name: %ld", IoErr());
+			return;
+		}
+		bufsize *= 2;
+	}
+
+	_isDirectory = false;
+	_isValid = false;
+
+	FileInfoBlock *fib = (FileInfoBlock*) AllocDosObject(DOS_FIB, NULL);
+	if (fib == NULL)
+	{
+		debug(6, "Failed to allocate memory for FileInfoBlock");
+		return;
+	}
+
+	if (Examine(lock, fib) != DOSFALSE)
+	{
+		_isDirectory = fib->fib_EntryType > 0;
+		if (_isDirectory)
+		{
+			if (fib->fib_EntryType != ST_ROOT)
+				_path += "/";
+			_lock = DupLock(lock);
+			_isValid = (_lock != NULL);
+		}
+		else
+		{
+			_isValid = true;
+		}
+	}
+	
+	FreeDosObject(DOS_FIB, fib);
+}
+
 ABoxFilesystemNode::ABoxFilesystemNode(const ABoxFilesystemNode& node)
 {
 	_displayName = node._displayName;
@@ -213,7 +224,27 @@
 	}
 }
 
-bool ABoxFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const
+AbstractFilesystemNode *ABoxFilesystemNode::getChild(const String &name) const {
+	assert(_isDirectory);
+	String newPath(_path);
+
+	if (_path.lastChar() != '/')
+		newPath += '/';
+	newPath += name;
+
+	BPTR lock = Lock(newPath.c_str(), SHARED_LOCK);
+
+	if (!lock)
+	{
+		return 0;
+    }
+
+	UnLock(lock);
+
+	return new ABoxFilesystemNode(newPath);
+}
+
+bool ABoxFilesystemNode::getChildren(AbstractFSList &list, ListMode mode) const
 {
 	if (!_isValid)
 	{
@@ -229,7 +260,7 @@
 	if (_lock == NULL)
 	{
 		/* This is the root node */
-		myList = listRoot();
+		list = getRootChildren();
 		return true;
 	}
 
@@ -263,7 +294,7 @@
 					if (entry)
 					{
 						if (entry->isValid())
-							myList.push_back(entry);
+							list.push_back(entry);
 						else
 							delete entry;
 					}
@@ -281,7 +312,7 @@
 	return true;
 }
 
-AbstractFilesystemNode *ABoxFilesystemNode::parent() const
+AbstractFilesystemNode *ABoxFilesystemNode::getParent() const
 {
 	AbstractFilesystemNode *node = NULL;
 
@@ -306,29 +337,9 @@
 	return node;
 }
 
-AbstractFilesystemNode *ABoxFilesystemNode::child(const String &name) const {
-	assert(_isDirectory);
-	String newPath(_path);
-
-	if (_path.lastChar() != '/')
-		newPath += '/';
-	newPath += name;
-
-	BPTR lock = Lock(newPath.c_str(), SHARED_LOCK);
-
-	if (!lock)
-	{
-		return 0;
-    }
-
-	UnLock(lock);
-
-	return new ABoxFilesystemNode(newPath);
-}
-
-AbstractFSList ABoxFilesystemNode::listRoot()
+AbstractFSList ABoxFilesystemNode::getRootChildren()
 {
-	AbstractFSList myList;
+	AbstractFSList list;
 	DosList *dosList;
 	CONST ULONG lockDosListFlags = LDF_READ | LDF_VOLUMES;
 	char name[256];
@@ -336,15 +347,15 @@
 	dosList = LockDosList(lockDosListFlags);
 	if (dosList == NULL)
 	{
-		return myList;
+		return list;
 	}
 
 	dosList = NextDosEntry(dosList, LDF_VOLUMES);
 	while (dosList)
 	{
-		if (dosList->dol_Type == DLT_VOLUME &&  // Should always be true, but ...
-			 dosList->dol_Name &&                                   // Same here
-			 dosList->dol_Task                                              // Will be NULL if volume is removed from drive but still in use by some program
+		if (dosList->dol_Type == DLT_VOLUME &&	// Should always be true, but ...
+			 dosList->dol_Name &&				// Same here
+			 dosList->dol_Task					// Will be NULL if volume is removed from drive but still in use by some program
 			)
 		{
 			ABoxFilesystemNode *entry;
@@ -362,7 +373,7 @@
 				if (entry)
 				{
 					if (entry->isValid())
-						myList.push_back(entry);
+						list.push_back(entry);
 					else
 						delete entry;
 				}
@@ -374,9 +385,7 @@
 
 	UnLockDosList(lockDosListFlags);
 
-	return myList;
+	return list;
 }
 
 #endif // defined(__MORPHOS__)
-
-

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/palmos/PalmOSFilesystemFactory.h"
+#include "backends/fs/palmos/palmos-fs.cpp"
+
+PalmOSFilesystemFactory *PalmOSFilesystemFactory::_instance = 0;
+
+PalmOSFilesystemFactory *PalmOSFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new PalmOSFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *PalmOSFilesystemFactory::makeRootFileNode() const {
+	return new PalmOSFilesystemNode();
+}
+
+AbstractFilesystemNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new PalmOSFilesystemNode();
+}
+
+AbstractFilesystemNode *PalmOSFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new PalmOSFilesystemNode(path);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef PALMOSFILESYSTEMFACTORY_H_
+#define PALMOSFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates PalmOSFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class PalmOSFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of PalmOSFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of PalmOSFilesytemFactory.
+	 */
+	static PalmOSFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~PalmOSFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	PalmOSFilesystemFactory() {};
+		
+private:
+	static PalmOSFilesystemFactory *_instance;
+};
+
+#endif /*PALMOSFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/PalmOSFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/palmos/palmos-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -27,36 +27,65 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-/*
+/**
  * Implementation of the ScummVM file system API based on PalmOS VFS API.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
-
 class PalmOSFilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
 	bool _isPseudoRoot;
-	String _path;
 	
 public:
+	/**
+	 * Creates a PalmOSFilesystemNode with the root node as path.
+	 */
 	PalmOSFilesystemNode();
+	
+	/**
+	 * Creates a POSIXFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
 	PalmOSFilesystemNode(const String &p);
 
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
 
 private:
-	static void addFile (AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
+	/**
+	 * Adds a single WindowsFilesystemNode to a given list.
+	 * This method is used by getChildren() to populate the directory entries list. 
+	 * 
+	 * @param list List to put the file entry node in.
+	 * @param mode Mode to use while adding the file entry to the list.
+	 * @param base String with the directory being listed.
+	 * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find.
+ 	 */
+	static void addFile(AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
 };
 
+/**
+ * Returns the last component of a given path.
+ * 
+ * Examples:
+ * 			/foo/bar.txt would return /bar.txt
+ * 			/foo/bar/    would return /bar/
+ *  
+ * @param str String containing the path.
+ * @return Pointer to the first char of the last component inside str.
+ */
 static const char *lastPathComponent(const Common::String &str) {
 	const char *start = str.c_str();
 	const char *cur = start + str.size() - 2;
@@ -92,19 +121,6 @@
 	list.push_back(new PalmOSFilesystemNode(entry));
 }
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new PalmOSFilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new PalmOSFilesystemNode(path);
-}
-
-
 PalmOSFilesystemNode::PalmOSFilesystemNode() {
 	_isDirectory = true;
 	_displayName = "Root";
@@ -119,13 +135,13 @@
 
 	UInt32 attr;
 	FileRef handle;
-	Err e = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
-	if (!e) {
-		e = VFSFileGetAttributes(handle, &attr);
+	Err error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
+	if (!error) {
+		error = VFSFileGetAttributes(handle, &attr);
 		VFSFileClose(handle);
 	}
 
-	if (e) {
+	if (error) {
 		_isValid = false;
 		_isDirectory = false;
 
@@ -136,8 +152,31 @@
 	_isPseudoRoot = false;
 }
 
-bool PalmOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
-	Err e;
+AbstractFilesystemNode *PalmOSFilesystemNode::getChild(const String &n) const {
+	assert(_isDirectory);
+	
+	String newPath(_path);
+	if (_path.lastChar() != '/')
+		newPath += '/';
+	newPath += n;
+
+	FileRef handle;
+	UInt32 attr;
+	Err error = VFSFileOpen(gVars->VFS.volRefNum, newPath.c_str(), vfsModeRead, &handle);
+	if (error)
+		return 0;
+	
+	error = VFSFileGetAttributes(handle, &attr);
+	VFSFileClose(handle);
+
+	if (error || !(attr & vfsFileAttrDirectory))
+		return 0;
+
+	return new PalmOSFilesystemNode(newPath);
+}
+
+bool PalmOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
+	Err error;
 	Char nameP[256];
 	FileInfoType desc;
 	FileRef handle;
@@ -145,14 +184,14 @@
 
 	desc.nameP = nameP;
 	desc.nameBufLen = 256;
-	e = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
+	error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
 
-	if (e)
+	if (error)
 		return false;
 	
 	while(dirIterator != expIteratorStop) {
-		e = VFSDirEntryEnumerate(handle, &dirIterator, &desc);
-		if (!e) {
+		error = VFSDirEntryEnumerate(handle, &dirIterator, &desc);
+		if (!error) {
 			addFile(myList, mode, _path.c_str(), &desc);
 		}
 	}
@@ -162,8 +201,7 @@
 	return true;
 }
 
-
-AbstractFilesystemNode *PalmOSFilesystemNode::parent() const {
+AbstractFilesystemNode *PalmOSFilesystemNode::getParent() const {
 	PalmOSFilesystemNode *p = 0;
 	
 	if (!_isPseudoRoot) {
@@ -177,31 +215,7 @@
 		p->_displayName = lastPathComponent(p->_path);
 		p->_isPseudoRoot =(p->_path == "/");
 	}
-	return p;
-}
-
-
-AbstractFilesystemNode *PalmOSFilesystemNode::child(const String &n) const {
-	assert(_isDirectory);
-	String newPath(_path);
-
-	if (_path.lastChar() != '/')
-		newPath += '/';
-	newPath += n;
-
-	FileRef handle;
-	UInt32 attr;
-	Err e = VFSFileOpen(gVars->VFS.volRefNum, newPath.c_str(), vfsModeRead, &handle);
-	if (e)
-		return 0;
 	
-	e = VFSFileGetAttributes(handle, &attr);
-	VFSFileClose(handle);
-
-	if (e || !(attr & vfsFileAttrDirectory))
-		return 0;
-
-	PalmOSFilesystemNode *p = new PalmOSFilesystemNode(newPath);
 	return p;
 }
 

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,25 @@
+#include "backends/fs/posix/POSIXFilesystemFactory.h"
+#include "backends/fs/posix/posix-fs.cpp"
+
+POSIXFilesystemFactory *POSIXFilesystemFactory::_instance = 0;
+
+POSIXFilesystemFactory *POSIXFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new POSIXFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const {
+	return new POSIXFilesystemNode();
+}
+
+AbstractFilesystemNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	char buf[MAXPATHLEN];
+	getcwd(buf, MAXPATHLEN);
+	return new POSIXFilesystemNode(buf, true);
+}
+
+AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new POSIXFilesystemNode(path, true);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef POSIXFILESYSTEMFACTORY_H_
+#define POSIXFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates POSIXFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class POSIXFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of POSIXFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of POSIXFilesytemFactory.
+	 */
+	static POSIXFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~POSIXFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	POSIXFilesystemFactory() {};
+		
+private:
+	static POSIXFilesystemFactory *_instance;
+};
+
+#endif /*POSIXFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/POSIXFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/posix/posix-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -22,7 +22,6 @@
 #if defined(UNIX)
 
 #include "common/stdafx.h"
-
 #include "backends/fs/abstract-fs.h"
 
 #ifdef MACOSX
@@ -34,33 +33,59 @@
 #include <stdio.h>
 #include <unistd.h>
 
-/*
+/**
  * Implementation of the ScummVM file system API based on POSIX.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
-
 class POSIXFilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
-	String _path;
 
 public:
+	/**
+	 * Creates a POSIXFilesystemNode with the root node as path.
+	 */
 	POSIXFilesystemNode();
+	
+	/**
+	 * Creates a POSIXFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 * @param verify true if the isValid and isDirectory flags should be verified during the construction.
+	 */
 	POSIXFilesystemNode(const String &path, bool verify);
-
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
-
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
+	
+private:
+	/**
+	 * Tests and sets the _isValid and _isDirectory flags, using the stat() function.
+	 */
+	virtual void setFlags();
 };
 
-
+/**
+ * Returns the last component of a given path.
+ * 
+ * Examples:
+ * 			/foo/bar.txt would return /bar.txt
+ * 			/foo/bar/    would return /bar/
+ *  
+ * @param str String containing the path.
+ * @return Pointer to the first char of the last component inside str.
+ */
 static const char *lastPathComponent(const Common::String &str) {
 	const char *start = str.c_str();
 	const char *cur = start + str.size() - 2;
@@ -72,20 +97,12 @@
 	return cur + 1;
 }
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	char buf[MAXPATHLEN];
-	getcwd(buf, MAXPATHLEN);
-	return new POSIXFilesystemNode(buf, true);
+void POSIXFilesystemNode::setFlags() {
+	struct stat st;
+	_isValid = (0 == stat(_path.c_str(), &st));
+	_isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;	
 }
 
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new POSIXFilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new POSIXFilesystemNode(path, true);
-}
-
 POSIXFilesystemNode::POSIXFilesystemNode() {
 /*  The Browser code now saves the last browsed directory into the config file.
     Hence the need to start at the "current" directory is far less, and we can
@@ -124,22 +141,33 @@
 	_isDirectory = true;
 
 	if (verify) {
-		struct stat st;
-		_isValid = (0 == stat(_path.c_str(), &st));
-		_isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;
+		setFlags();
 	}
 }
 
-bool POSIXFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+AbstractFilesystemNode *POSIXFilesystemNode::getChild(const String &n) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
 	assert(_isDirectory);
+	
+	String newPath(_path);
+	if (_path.lastChar() != '/')
+		newPath += '/';
+	newPath += n;
+	
+	return new POSIXFilesystemNode(newPath, true);
+}
+
+bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
+	assert(_isDirectory);
+	
 	DIR *dirp = opendir(_path.c_str());
-
 	struct dirent *dp;
 
 	if (dirp == NULL)
 		return false;
 
-	// ... loop over dir entries using readdir
+	// loop over dir entries using readdir
 	while ((dp = readdir(dirp)) != NULL) {
 		// Skip 'invisible' files
 		if (dp->d_name[0] == '.')
@@ -153,18 +181,18 @@
 		POSIXFilesystemNode entry(newPath, false);
 
 #if defined(SYSTEM_NOT_SUPPORTING_D_TYPE)
-		// TODO: d_type is not part of POSIX, so it might not be supported
-		// on some of our targets. For those systems where it isn't supported,
-		// add this #elif case, which tries to use stat() instead.
-		struct stat st;
-		entry._isValid = (0 == stat(entry._path.c_str(), &st));
-		entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false;
+		/* TODO: d_type is not part of POSIX, so it might not be supported
+		 * on some of our targets. For those systems where it isn't supported,
+		 * add this #elif case, which tries to use stat() instead.
+		 * 
+		 * The d_type method is used to avoid costly recurrent stat() calls in big
+		 * directories.
+		 */
+		entry.setFlags();
 #else
 		if (dp->d_type == DT_UNKNOWN) {
 			// Fall back to stat()
-			struct stat st;
-			entry._isValid = (0 == stat(entry._path.c_str(), &st));
-			entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false;
+			entry.setFlags();
 		} else {
 			entry._isValid = (dp->d_type == DT_DIR) || (dp->d_type == DT_REG) || (dp->d_type == DT_LNK);
 			if (dp->d_type == DT_LNK) {
@@ -191,35 +219,22 @@
 
 		if (entry._isDirectory)
 			entry._path += "/";
+			
 		myList.push_back(new POSIXFilesystemNode(entry));
 	}
 	closedir(dirp);
+	
 	return true;
 }
 
-AbstractFilesystemNode *POSIXFilesystemNode::parent() const {
+AbstractFilesystemNode *POSIXFilesystemNode::getParent() const {
 	if (_path == "/")
 		return 0;
 
 	const char *start = _path.c_str();
 	const char *end = lastPathComponent(_path);
 
-	POSIXFilesystemNode *p = new POSIXFilesystemNode(String(start, end - start), false);
-
-	return p;
+	return new POSIXFilesystemNode(String(start, end - start), false);
 }
 
-AbstractFilesystemNode *POSIXFilesystemNode::child(const String &n) const {
-	// FIXME: Pretty lame implementation! We do no error checking to speak
-	// of, do not check if this is a special node, etc.
-	assert(_isDirectory);
-	String newPath(_path);
-	if (_path.lastChar() != '/')
-		newPath += '/';
-	newPath += n;
-	POSIXFilesystemNode *p = new POSIXFilesystemNode(newPath, true);
-
-	return p;
-}
-
-#endif // defined(UNIX)
+#endif //#if defined(UNIX)

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/ps2/Ps2FilesystemFactory.h"
+#include "backends/fs/ps2/ps2-fs.cpp"
+
+Ps2FilesystemFactory *Ps2FilesystemFactory::_instance = 0;
+
+Ps2FilesystemFactory *Ps2FilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new Ps2FilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const {
+	return new Ps2FilesystemNode();
+}
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new Ps2FilesystemNode();
+}
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const {
+	return new Ps2FilesystemNode(path);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef PS2FILESYSTEMFACTORY_H_
+#define PS2FILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates PS2FilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class Ps2FilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of Ps2FilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of Ps2FilesytemFactory.
+	 */
+	static Ps2FilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~Ps2FilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	Ps2FilesystemFactory() {};
+		
+private:
+	static Ps2FilesystemFactory *_instance;
+};
+
+#endif /*PS2FILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/Ps2FilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/ps2/ps2-fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -29,44 +29,49 @@
 extern AsyncFio fio;
 extern OSystem_PS2 *g_systemPs2;
 
+/**
+ * Implementation of the ScummVM file system API based on the Ps2SDK.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
+ */
 class Ps2FilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isRoot;
-	String _path;
 
 public:
-	Ps2FilesystemNode(void);
+	/**
+	 * Creates a PS2FilesystemNode with the root node as path.
+	 */
+	Ps2FilesystemNode();
+	
+	/**
+	 * Creates a PS2FilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 */
+	Ps2FilesystemNode(const String &path);
+	
+	/**
+	 * Copy constructor.
+	 */
 	Ps2FilesystemNode(const Ps2FilesystemNode *node);
-	Ps2FilesystemNode(const String &path);
 
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return !_isRoot; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 
-	//virtual FSList listDir(ListMode) const;
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
 	virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
 };
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot(void) {
-	return new Ps2FilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new Ps2FilesystemNode(path);
-}
-
-Ps2FilesystemNode::Ps2FilesystemNode(void) {
+Ps2FilesystemNode::Ps2FilesystemNode() {
 	_isDirectory = true;
 	_isRoot = true;
 	_displayName = "PlayStation 2";
@@ -105,8 +110,42 @@
 	_isRoot = node->_isRoot;
 }
 
-bool Ps2FilesystemNode::listDir(AbstractFSList &list, ListMode mode) const {
+AbstractFilesystemNode *Ps2FilesystemNode::getChild(const String &n) const {
 	if (!_isDirectory)
+		return NULL;
+
+	char listDir[256];
+	sprintf(listDir, "%s/", _path.c_str());
+	int fd = fio.dopen(listDir);
+	
+	if (fd >= 0) {
+		iox_dirent_t dirent;
+		
+		while (fio.dread(fd, &dirent) > 0) {
+			if (strcmp(n.c_str(), dirent.name) == 0) {
+				Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
+
+				dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
+				dirEntry->_isRoot = false;
+
+				dirEntry->_path = _path;
+				dirEntry->_path += "/";
+				dirEntry->_path += dirent.name;
+
+				dirEntry->_displayName = dirent.name;
+
+				fio.dclose(fd);
+				return dirEntry;
+			}
+		}
+		fio.dclose(fd);
+	}
+	
+	return NULL;
+}
+
+bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode) const {
+	if (!_isDirectory)
 		return false;
 
 	if (_isRoot) {
@@ -132,6 +171,7 @@
 	} else {
 		char listDir[256];
 		int fd;
+		
 		if (_path.lastChar() == '/')
 			fd = fio.dopen(_path.c_str());
 		else {
@@ -170,7 +210,7 @@
 	}
 }
 
-AbstractFilesystemNode *Ps2FilesystemNode::parent() const {
+AbstractFilesystemNode *Ps2FilesystemNode::getParent() const {
 	if (_isRoot)
 		return new Ps2FilesystemNode(this);
 
@@ -188,36 +228,3 @@
 	else
 		return new Ps2FilesystemNode();
 }
-
-AbstractFilesystemNode *Ps2FilesystemNode::child(const String &n) const {
-	if (!_isDirectory)
-		return NULL;
-
-	char listDir[256];
-	sprintf(listDir, "%s/", _path.c_str());
-	int fd = fio.dopen(listDir);
-	
-	if (fd >= 0) {
-		iox_dirent_t dirent;
-
-		while (fio.dread(fd, &dirent) > 0) {
-			if (strcmp(n.c_str(), dirent.name) == 0) {
-				Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
-
-				dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
-				dirEntry->_isRoot = false;
-
-				dirEntry->_path = _path;
-				dirEntry->_path += "/";
-				dirEntry->_path += dirent.name;
-
-				dirEntry->_displayName = dirent.name;
-
-				fio.dclose(fd);
-				return dirEntry;
-			}
-		}
-		fio.dclose(fd);
-	}
-	return NULL;
-}

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.cpp	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,23 @@
+#include "backends/fs/psp/PSPFilesystemFactory.h"
+#include "backends/fs/psp/psp_fs.cpp"
+
+PSPFilesystemFactory *PSPFilesystemFactory::_instance = 0;
+
+PSPFilesystemFactory *PSPFilesystemFactory::instance(){
+	if(_instance == 0){
+		_instance = new PSPFilesystemFactory();
+	}
+	return _instance;
+}
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const {
+	return new PSPFilesystemNode();
+}
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const {
+	return new PSPFilesystemNode();
+}
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const String &path) const {
+	return new PSPFilesystemNode(path, true);
+}


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.cpp
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Added: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.h
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.h	                        (rev 0)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.h	2007-05-03 02:39:33 UTC (rev 26739)
@@ -0,0 +1,38 @@
+#ifndef PSPFILESYSTEMFACTORY_H_
+#define PSPFILESYSTEMFACTORY_H_
+
+#include "backends/fs/AbstractFilesystemFactory.h"
+
+/**
+ * Creates PSPFilesystemNode objects.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class PSPFilesystemFactory : public AbstractFilesystemFactory {	
+public:
+	typedef Common::String String;
+	
+	/**
+	 * Creates an instance of PSPFilesystemFactory using the Singleton pattern.
+	 * 
+	 * @return A unique instance of PSPFilesytemFactory.
+	 */
+	static PSPFilesystemFactory *instance();
+	
+	/**
+	 * Destructor.
+	 */
+	virtual ~PSPFilesystemFactory() {};
+		
+	virtual AbstractFilesystemNode *makeRootFileNode() const;
+	virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+	virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+	
+protected:
+	PSPFilesystemFactory() {};
+		
+private:
+	static PSPFilesystemFactory *_instance;
+};
+
+#endif /*PSPFILESYSTEMFACTORY_H_*/


Property changes on: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/PSPFilesystemFactory.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp_fs.cpp
===================================================================
--- scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp_fs.cpp	2007-05-02 23:27:25 UTC (rev 26738)
+++ scummvm/branches/gsoc2007-fsnode/backends/fs/psp/psp_fs.cpp	2007-05-03 02:39:33 UTC (rev 26739)
@@ -23,8 +23,8 @@
  */
 
 #ifdef __PSP__
+
 #include "engines/engine.h"
-
 #include "backends/fs/abstract-fs.h"
 
 #include <sys/stat.h>
@@ -32,39 +32,62 @@
 
 #define	ROOT_PATH	"ms0:/"
 
-
-/*
+/**
  * Implementation of the ScummVM file system API based on PSPSDK API.
+ * 
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
  */
-
 class PSPFilesystemNode : public AbstractFilesystemNode {
 protected:
 	String _displayName;
+	String _path;
 	bool _isDirectory;
 	bool _isValid;
-	String _path;
 	
 public:
+	/**
+	 * Creates a PSPFilesystemNode with the root node as path.
+	 */
 	PSPFilesystemNode();
+	
+	/**
+	 * Creates a PSPFilesystemNode for a given path.
+	 * 
+	 * @param path String with the path the new node should point to.
+	 * @param verify true if the isValid and isDirectory flags should be verified during the construction.
+	 */
 	PSPFilesystemNode(const Common::String &p, bool verify);
 
-	virtual String displayName() const { return _displayName; }
-	virtual String name() const { return _displayName; }
+	virtual String getDisplayName() const { return _displayName; }
+	virtual String getName() const { return _displayName; }
+	virtual String getPath() const { return _path; }
+	virtual bool isDirectory() const { return _isDirectory; }
 	virtual bool isValid() const { return _isValid; }
-	virtual bool isDirectory() const { return _isDirectory; }
-	virtual String path() const { return _path; }
 
-	virtual bool listDir(AbstractFSList &list, ListMode mode) const;
-	virtual AbstractFilesystemNode *parent() const;
-	virtual AbstractFilesystemNode *child(const String &n) const;
+	virtual AbstractFilesystemNode *getChild(const String &n) const;
+	virtual bool getChildren(AbstractFSList &list, ListMode mode) const;
+	virtual AbstractFilesystemNode *getParent() const;
 };
 
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-	return AbstractFilesystemNode::getRoot();
-}
+/**
+ * Returns the last component of a given path.
+ * 
+ * Examples:
+ * 			/foo/bar.txt would return /bar.txt
+ * 			/foo/bar/    would return /bar/
+ *  
+ * @param str String containing the path.
+ * @return Pointer to the first char of the last component inside str.
+ */
+static const char *lastPathComponent(const Common::String &str) {
+	const char *start = str.c_str();
+	const char *cur = start + str.size() - 2;
 
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
-	return new PSPFilesystemNode();
+	while (cur >= start && *cur != '/') {
+		--cur;
+	}
+
+	return cur + 1;
 }
 
 PSPFilesystemNode::PSPFilesystemNode() {
@@ -89,12 +112,20 @@
 	}       
 }
 
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
-	return new PSPFilesystemNode(path, true);
+AbstractFilesystemNode *PSPFilesystemNode::getChild(const String &n) const {
+	// FIXME: Pretty lame implementation! We do no error checking to speak
+	// of, do not check if this is a special node, etc.
+	assert(_isDirectory);
+	
+	String newPath(_path);
+	if (_path.lastChar() != '/')
+		newPath += '/';
+	newPath += n;
+
+	return new PSPFilesystemNode(newPath, true);
 }
 
-
-bool PSPFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode) const {
 	assert(_isDirectory);
 
 	int dfd  = sceIoDopen(_path.c_str());
@@ -133,18 +164,7 @@
 	}
 }
 
-static const char *lastPathComponent(const Common::String &str) {
-	const char *start = str.c_str();
-	const char *cur = start + str.size() - 2;
-
-	while (cur >= start && *cur != '/') {
-		--cur;
-	}
-
-	return cur + 1;
-}
-
-AbstractFilesystemNode *PSPFilesystemNode::parent() const {
+AbstractFilesystemNode *PSPFilesystemNode::getParent() const {
 	assert(_isValid);
 	
 	if (_path == ROOT_PATH)
@@ -153,22 +173,7 @@
 	const char *start = _path.c_str();

@@ Diff output truncated at 100000 characters. @@

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