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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Jan 23 05:36:18 CET 2009


Revision: 36020
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36020&view=rev
Author:   fingolfin
Date:     2009-01-23 04:36:18 +0000 (Fri, 23 Jan 2009)

Log Message:
-----------
Renamed ArchiveMember::open -> createReadStream, and made it a cv member (const); same for Archive::openFile

Modified Paths:
--------------
    scummvm/trunk/common/archive.cpp
    scummvm/trunk/common/archive.h
    scummvm/trunk/common/fs.h
    scummvm/trunk/common/unzip.cpp
    scummvm/trunk/common/unzip.h
    scummvm/trunk/engines/kyra/resource.cpp
    scummvm/trunk/engines/kyra/resource_intern.cpp
    scummvm/trunk/engines/kyra/resource_intern.h
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/parallaction/disk_ns.cpp
    scummvm/trunk/gui/ThemeEngine.cpp

Modified: scummvm/trunk/common/archive.cpp
===================================================================
--- scummvm/trunk/common/archive.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/common/archive.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -38,7 +38,7 @@
 	return _name;
 }
 
-SeekableReadStream *GenericArchiveMember::open() {
+SeekableReadStream *GenericArchiveMember::createReadStream() const {
 	return _parent->openFile(_name);
 }
 
@@ -99,7 +99,7 @@
 	return _node;
 }
 
-FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) {
+FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) const {
 	// make caching as lazy as possible
 	if (!name.empty()) {
 		ensureCached();
@@ -136,7 +136,7 @@
 	return ArchiveMemberPtr(new FSNode(node));
 }
 
-SeekableReadStream *FSDirectory::openFile(const String &name) {
+SeekableReadStream *FSDirectory::openFile(const String &name) const {
 	if (name.empty() || !_node.isDirectory())
 		return 0;
 
@@ -169,7 +169,7 @@
 	return new FSDirectory(prefix, node, depth);
 }
 
-void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) {
+void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) const {
 	if (depth <= 0)
 		return;
 
@@ -203,7 +203,7 @@
 
 }
 
-void FSDirectory::ensureCached() {
+void FSDirectory::ensureCached() const  {
 	if (_cached)
 		return;
 	cacheDirectoryRecursive(_node, _depth, _prefix);
@@ -434,7 +434,7 @@
 	return ArchiveMemberPtr();
 }
 
-SeekableReadStream *SearchSet::openFile(const String &name) {
+SeekableReadStream *SearchSet::openFile(const String &name) const {
 	if (name.empty())
 		return 0;
 

Modified: scummvm/trunk/common/archive.h
===================================================================
--- scummvm/trunk/common/archive.h	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/common/archive.h	2009-01-23 04:36:18 UTC (rev 36020)
@@ -50,7 +50,7 @@
 class ArchiveMember {
 public:
 	virtual ~ArchiveMember() { }
-	virtual SeekableReadStream *open() = 0;
+	virtual SeekableReadStream *createReadStream() const = 0;
 	virtual String getName() const = 0;
 	virtual String getDisplayName() const { return getName(); }
 };
@@ -75,7 +75,7 @@
 public:
 	GenericArchiveMember(String name, Archive *parent);
 	String getName() const;
-	SeekableReadStream *open();
+	SeekableReadStream *createReadStream() const;
 };
 
 
@@ -120,7 +120,7 @@
 	 * Create a stream bound to a file in the archive.
 	 * @return the newly created input stream
 	 */
-	virtual SeekableReadStream *openFile(const String &name) = 0;
+	virtual SeekableReadStream *openFile(const String &name) const = 0;
 };
 
 
@@ -197,7 +197,7 @@
 	 * Implements openFile from Archive base class. The current policy is
 	 * opening the first file encountered that matches the name.
 	 */
-	virtual SeekableReadStream *openFile(const String &name);
+	virtual SeekableReadStream *openFile(const String &name) const;
 };
 
 

Modified: scummvm/trunk/common/fs.h
===================================================================
--- scummvm/trunk/common/fs.h	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/common/fs.h	2009-01-23 04:36:18 UTC (rev 36020)
@@ -223,11 +223,6 @@
 	 * @return pointer to the stream object, 0 in case of a failure
 	 */
 	virtual WriteStream *createWriteStream() const;
-
-	// Compatibility with ArchiveMember API.
-	SeekableReadStream *open() {
-		return createReadStream();
-	}
 };
 
 /**
@@ -262,22 +257,24 @@
 class FSDirectory : public Archive {
 	FSNode	_node;
 
+	String	_prefix;	// string that is prepended to each cache item key
+	void setPrefix(const String &prefix);
+
 	// Caches are case insensitive, clashes are dealt with when creating
 	// Key is stored in lowercase.
 	typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache;
-	NodeCache	_fileCache, _subDirCache;
-	String	_prefix;	// string that is prepended to each cache item key
-	void setPrefix(const String &prefix);
+	mutable NodeCache	_fileCache, _subDirCache;
+	mutable bool _cached;
+	mutable int	_depth;
 
 	// look for a match
-	FSNode lookupCache(NodeCache &cache, const String &name);
+	FSNode lookupCache(NodeCache &cache, const String &name) const;
 
 	// cache management
-	void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix);
+	void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) const;
+
 	// fill cache if not already cached
-	void ensureCached();
-	bool _cached;
-	int	_depth;
+	void ensureCached() const;
 
 public:
 	/**
@@ -336,7 +333,7 @@
 	 * Open the specified file. A full match of relative path and filename is needed
 	 * for success.
 	 */
-	virtual SeekableReadStream *openFile(const String &name);
+	virtual SeekableReadStream *openFile(const String &name) const;
 };
 
 

Modified: scummvm/trunk/common/unzip.cpp
===================================================================
--- scummvm/trunk/common/unzip.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/common/unzip.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -1428,7 +1428,7 @@
 	return ArchiveMemberPtr(new GenericArchiveMember(name, this));
 }
 
-Common::SeekableReadStream *ZipArchive::openFile(const Common::String &name) {
+Common::SeekableReadStream *ZipArchive::openFile(const Common::String &name) const {
 	if (!_zipFile)
 		return 0;
 

Modified: scummvm/trunk/common/unzip.h
===================================================================
--- scummvm/trunk/common/unzip.h	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/common/unzip.h	2009-01-23 04:36:18 UTC (rev 36020)
@@ -62,7 +62,7 @@
 	virtual bool hasFile(const String &name);
 	virtual int listMembers(ArchiveMemberList &list);
 	virtual ArchiveMemberPtr getMember(const String &name);
-	virtual SeekableReadStream *openFile(const String &name);
+	virtual SeekableReadStream *openFile(const String &name) const;
 };
 
 }	// End of namespace Common

Modified: scummvm/trunk/engines/kyra/resource.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/engines/kyra/resource.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -319,7 +319,7 @@
 	if (cachedArchive != _archiveCache.end())
 		return cachedArchive->_value;
 
-	Common::SeekableReadStream *stream = member->open();
+	Common::SeekableReadStream *stream = member->createReadStream();
 
 	if (!stream)
 		return 0;

Modified: scummvm/trunk/engines/kyra/resource_intern.cpp
===================================================================
--- scummvm/trunk/engines/kyra/resource_intern.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/engines/kyra/resource_intern.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -69,12 +69,12 @@
 	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
 }
 
-Common::SeekableReadStream *PlainArchive::openFile(const Common::String &name) {
+Common::SeekableReadStream *PlainArchive::openFile(const Common::String &name) const {
 	FileMap::const_iterator fDesc = _files.find(name);
 	if (fDesc == _files.end())
 		return 0;
 
-	Common::SeekableReadStream *parent = _file->open();
+	Common::SeekableReadStream *parent = _file->createReadStream();
 	if (!parent)
 		return 0;
 
@@ -124,7 +124,7 @@
 	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
 }
 
-Common::SeekableReadStream *CachedArchive::openFile(const Common::String &name) {
+Common::SeekableReadStream *CachedArchive::openFile(const Common::String &name) const {
 	FileMap::const_iterator fDesc = _files.find(name);
 	if (fDesc == _files.end())
 		return 0;

Modified: scummvm/trunk/engines/kyra/resource_intern.h
===================================================================
--- scummvm/trunk/engines/kyra/resource_intern.h	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/engines/kyra/resource_intern.h	2009-01-23 04:36:18 UTC (rev 36020)
@@ -52,7 +52,7 @@
 	bool hasFile(const Common::String &name);
 	int listMembers(Common::ArchiveMemberList &list);
 	Common::ArchiveMemberPtr getMember(const Common::String &name);
-	Common::SeekableReadStream *openFile(const Common::String &name);
+	Common::SeekableReadStream *openFile(const Common::String &name) const;
 private:
 	struct Entry {
 		uint32 offset;
@@ -82,7 +82,7 @@
 	bool hasFile(const Common::String &name);
 	int listMembers(Common::ArchiveMemberList &list);
 	Common::ArchiveMemberPtr getMember(const Common::String &name);
-	Common::SeekableReadStream *openFile(const Common::String &name);
+	Common::SeekableReadStream *openFile(const Common::String &name) const;
 private:
 	struct Entry {
 		byte *data;

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -144,7 +144,7 @@
 
 	bool foundWorkingKyraDat = false;
 	for (Common::ArchiveMemberList::iterator i = kyraDatFiles.begin(); i != kyraDatFiles.end(); ++i) {
-		Common::SeekableReadStream *file = (*i)->open();
+		Common::SeekableReadStream *file = (*i)->createReadStream();
 		if (!checkKyraDat(file)) {
 			delete file;
 			continue;

Modified: scummvm/trunk/engines/parallaction/disk_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk_ns.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/engines/parallaction/disk_ns.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -72,13 +72,13 @@
 	uint32			_archiveOffsets[MAX_ARCHIVE_ENTRIES];
 	uint32			_numFiles;
 
-	uint32 			lookup(const char *name);
+	uint32 			lookup(const char *name) const;
 
 public:
 	NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features);
 	~NSArchive();
 
-	Common::SeekableReadStream *openFile(const Common::String &name);
+	Common::SeekableReadStream *openFile(const Common::String &name) const;
 	bool hasFile(const Common::String &name);
 	int listMembers(Common::ArchiveMemberList &list);
 	Common::ArchiveMemberPtr getMember(const Common::String &name);
@@ -119,7 +119,7 @@
 	delete _stream;
 }
 
-uint32 NSArchive::lookup(const char *name) {
+uint32 NSArchive::lookup(const char *name) const {
 	uint32 i = 0;
  	for ( ; i < _numFiles; i++) {
 		if (!scumm_stricmp(_archiveDir[i], name)) break;
@@ -127,7 +127,7 @@
 	return i;
 }
 
-Common::SeekableReadStream *NSArchive::openFile(const Common::String &name) {
+Common::SeekableReadStream *NSArchive::openFile(const Common::String &name) const {
 	debugC(3, kDebugDisk, "NSArchive::openFile(%s)", name.c_str());
 
 	if (name.empty())

Modified: scummvm/trunk/gui/ThemeEngine.cpp
===================================================================
--- scummvm/trunk/gui/ThemeEngine.cpp	2009-01-23 04:09:57 UTC (rev 36019)
+++ scummvm/trunk/gui/ThemeEngine.cpp	2009-01-23 04:36:18 UTC (rev 36020)
@@ -718,7 +718,7 @@
 	for (Common::ArchiveMemberList::iterator i = members.begin(); i != members.end(); ++i) {
 		assert((*i)->getName().hasSuffix(".stx"));
 
-		if (_parser->loadStream((*i)->open()) == false) {
+		if (_parser->loadStream((*i)->createReadStream()) == false) {
 			warning("Failed to load STX file '%s'", (*i)->getDisplayName().c_str());
 			_parser->close();
 			return false;


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