[Scummvm-cvs-logs] SF.net SVN: scummvm:[33590] scummvm/trunk/common

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Aug 3 20:35:51 CEST 2008


Revision: 33590
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33590&view=rev
Author:   fingolfin
Date:     2008-08-03 18:35:51 +0000 (Sun, 03 Aug 2008)

Log Message:
-----------
FilesystemNode code: some comment cleanup; added FilesystemNode::openForReading() and openForWriting() methods (for now these are simple wrappers around Common::File)

Modified Paths:
--------------
    scummvm/trunk/common/fs.cpp
    scummvm/trunk/common/fs.h

Modified: scummvm/trunk/common/fs.cpp
===================================================================
--- scummvm/trunk/common/fs.cpp	2008-08-03 18:35:19 UTC (rev 33589)
+++ scummvm/trunk/common/fs.cpp	2008-08-03 18:35:51 UTC (rev 33590)
@@ -23,10 +23,13 @@
  */
 
 #include "common/util.h"
+#include "common/file.h"
 #include "common/system.h"
 #include "backends/fs/abstract-fs.h"
 #include "backends/fs/fs-factory.h"
 
+//namespace Common {
+
 FilesystemNode::FilesystemNode() {
 }
 
@@ -170,3 +173,41 @@
 
 	return !results.empty();
 }
+
+Common::SeekableReadStream *FilesystemNode::openForReading() {
+	if (_realNode == 0)
+		return 0;
+#if 0
+	return _realNode->openForReading();
+#else
+	// FIXME: Until we support openForReading in AbstractFilesystemNode,
+	// we just use Common::File.
+	Common::File *confFile = new Common::File();
+	assert(confFile);
+	if (!confFile->open(*this)) {
+		delete confFile;
+		confFile = 0;
+	}
+	return confFile;
+#endif
+}
+
+Common::WriteStream *FilesystemNode::openForWriting() {
+	if (_realNode == 0)
+		return 0;
+#if 0
+	return _realNode->openForWriting();
+#else
+	// FIXME: Until we support openForWriting in AbstractFilesystemNode,
+	// we just use Common::DumpFile.
+	Common::DumpFile *confFile = new Common::DumpFile();
+	assert(confFile);
+	if (!confFile->open(*this)) {
+		delete confFile;
+		confFile = 0;
+	}
+	return confFile;
+#endif
+}
+
+//}	// End of namespace Common

Modified: scummvm/trunk/common/fs.h
===================================================================
--- scummvm/trunk/common/fs.h	2008-08-03 18:35:19 UTC (rev 33589)
+++ scummvm/trunk/common/fs.h	2008-08-03 18:35:51 UTC (rev 33590)
@@ -29,10 +29,18 @@
 #include "common/ptr.h"
 #include "common/str.h"
 
+class AbstractFilesystemNode;
+
+namespace Common {
+	class SeekableReadStream;
+	class WriteStream;
+}
+
 //namespace Common {
 
 class FilesystemNode;
-class AbstractFilesystemNode;
+//class SeekableReadStream;
+//class WriteStream;
 
 /**
  * List of multiple file system nodes. E.g. the contents of a given directory.
@@ -49,22 +57,6 @@
  * To this end, we abstract away from paths; implementations can be based on
  * paths (and it's left to them whether / or \ or : is the path separator :-);
  * but it is also possible to use inodes or vrefs (MacOS 9) or anything else.
- *
- * NOTE: Backends still have to provide a way to extract a path from a FSIntern
- *
- * You may ask now: "isn't this cheating? Why do we go through all this when we use
- * a path in the end anyway?!?".
- * Well, for once as long as we don't provide our own file open/read/write API, we
- * still have to use fopen(). Since all our targets already support fopen(), it should
- * be possible to get a fopen() compatible string for any file system node.
- *
- * Secondly, with this abstraction layer, we still avoid a lot of complications based on
- * differences in FS roots, different path separators, or even systems with no real
- * paths (MacOS 9 doesn't even have the notion of a "current directory").
- * And if we ever want to support devices with no FS in the classical sense (Palm...),
- * we can build upon this.
- *
- * This class acts as a wrapper around the AbstractFilesystemNode class defined in backends/fs.
  */
 class FilesystemNode {
 private:
@@ -108,9 +100,9 @@
 	bool operator<(const FilesystemNode& node) const;
 
 	/**
-	 * Indicates whether the object referred by this path exists in the filesystem or not.
+	 * Indicates whether the object referred by this node exists in the filesystem or not.
 	 *
-	 * @return bool true if the path exists, false otherwise.
+	 * @return bool true if the node exists, false otherwise.
 	 */
 	virtual bool exists() const;
 
@@ -168,7 +160,7 @@
 	FilesystemNode getParent() const;
 
 	/**
-	 * Indicates whether the path refers to a directory or not.
+	 * Indicates whether the node refers to a directory or not.
 	 *
 	 * @todo Currently we assume that a node that is not a directory
 	 * automatically is a file (ignoring things like symlinks or pipes).
@@ -179,28 +171,28 @@
 	virtual bool isDirectory() const;
 
 	/**
-	 * Indicates whether the object referred by this path can be read from or not.
+	 * Indicates whether the object referred by this node can be read from or not.
 	 *
-	 * If the path refers to a directory, readability implies being able to read
+	 * If the node refers to a directory, readability implies being able to read
 	 * and list the directory entries.
 	 *
-	 * If the path refers to a file, readability implies being able to read the
+	 * If the node refers to a file, readability implies being able to read the
 	 * contents of the file.
 	 *
-	 * @return bool true if the object can be read, false otherwise.
+	 * @return true if the object can be read, false otherwise.
 	 */
 	virtual bool isReadable() const;
 
 	/**
-	 * Indicates whether the object referred by this path can be written to or not.
+	 * Indicates whether the object referred by this node can be written to or not.
 	 *
-	 * If the path refers to a directory, writability implies being able to modify
+	 * If the node refers to a directory, writability implies being able to modify
 	 * the directory entry (i.e. rename the directory, remove it or write files inside of it).
 	 *
-	 * If the path refers to a file, writability implies being able to write data
+	 * If the node refers to a file, writability implies being able to write data
 	 * to the file.
 	 *
-	 * @return bool true if the object can be written to, false otherwise.
+	 * @return true if the object can be written to, false otherwise.
 	 */
 	virtual bool isWritable() const;
 
@@ -221,6 +213,25 @@
 	 * @return true if matches could be found, false otherwise.
 	 */
 	virtual bool lookupFile(FSList &results, const Common::String &pattern, bool hidden, bool exhaustive, int depth = -1) const;
+	
+	
+	/**
+	 * Creates a SeekableReadStream instance corresponding to the file
+	 * referred by this node. This assumes that the node actually refers
+	 * to a readable file. If this is not the case, 0 is returned.
+	 *
+	 * @return pointer to the stream object, 0 in case of a failure
+	 */
+	virtual Common::SeekableReadStream *openForReading();
+
+	/**
+	 * Creates a WriteStream instance corresponding to the file
+	 * referred by this node. This assumes that the node actually refers
+	 * to a readable file. If this is not the case, 0 is returned.
+	 *
+	 * @return pointer to the stream object, 0 in case of a failure
+	 */
+	virtual Common::WriteStream *openForWriting();
 };
 
 //} // End of namespace Common


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