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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Sep 3 19:07:17 CEST 2008


Revision: 34312
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34312&view=rev
Author:   fingolfin
Date:     2008-09-03 17:07:13 +0000 (Wed, 03 Sep 2008)

Log Message:
-----------
Changed Archive::openFile to return a SeekableReadStream* instead of a FilePtr

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

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2008-09-03 17:06:24 UTC (rev 34311)
+++ scummvm/trunk/common/archive.cpp	2008-09-03 17:07:13 UTC (rev 34312)
@@ -70,19 +70,19 @@
 	return node.exists();
 }
 
-FilePtr FSDirectory::openFile(const String &name) {
+SeekableReadStream *FSDirectory::openFile(const String &name) {
 	if (name.empty() || !_node.isDirectory()) {
-		return FilePtr();
+		return 0;
 	}
 
 	FilesystemNode node = lookupCache(_fileCache, name);
 
 	if (!node.exists()) {
 		warning("FSDirectory::openFile: Trying to open a FilesystemNode which does not exist");
-		return FilePtr();
+		return 0;
 	} else if (node.isDirectory()) {
 		warning("FSDirectory::openFile: Trying to open a FilesystemNode which is a directory");
-		return FilePtr();
+		return 0;
 	}
 
 	SeekableReadStream *stream = node.openForReading();
@@ -90,7 +90,7 @@
 		warning("FSDirectory::openFile: Can't create stream for file '%s'", name.c_str());
 	}
 
-	return FilePtr(stream);
+	return stream;
 }
 
 SharedPtr<FSDirectory> FSDirectory::getSubDirectory(const String &name) {
@@ -269,9 +269,9 @@
 	return matches;
 }
 
-FilePtr SearchSet::openFile(const String &name) {
+SeekableReadStream *SearchSet::openFile(const String &name) {
 	if (name.empty()) {
-		return FilePtr();
+		return 0;
 	}
 
 	ArchiveList::iterator it = _list.begin();
@@ -281,7 +281,7 @@
 		}
 	}
 
-	return FilePtr();
+	return 0;
 }
 
 

Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h	2008-09-03 17:06:24 UTC (rev 34311)
+++ scummvm/trunk/common/archive.h	2008-09-03 17:07:13 UTC (rev 34312)
@@ -35,6 +35,10 @@
 
 namespace Common {
 
+/**
+ * FilePtr is a convenient way to keep track of a SeekableReadStream without
+ * having to worry about releasing its memory.
+ */
 typedef SharedPtr<SeekableReadStream> FilePtr;
 
 /**
@@ -75,7 +79,7 @@
 	 * Create a stream bound to a file in the archive.
 	 * @return The newly created input stream.
 	 */
-	virtual FilePtr openFile(const String &name) = 0;
+	virtual SeekableReadStream *openFile(const String &name) = 0;
 };
 
 
@@ -136,7 +140,7 @@
 
 	virtual bool hasFile(const String &name);
 	virtual int matchPattern(StringList &list, const String &pattern);
-	virtual FilePtr openFile(const String &name);
+	virtual SeekableReadStream *openFile(const String &name);
 };
 
 
@@ -193,7 +197,7 @@
 	 * Implements openFile from Archive base class. The current policy is
 	 * opening the first file encountered that matches the name.
 	 */
-	virtual FilePtr openFile(const String &name);
+	virtual SeekableReadStream *openFile(const String &name);
 };
 
 } // 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