[Scummvm-cvs-logs] SF.net SVN: scummvm:[53248] scummvm/trunk/engines/sword25/package

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 00:47:38 CEST 2010


Revision: 53248
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53248&view=rev
Author:   sev
Date:     2010-10-12 22:47:38 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SWORD25: Changed signature of FS searching method. Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/package/packagemanager.h
    scummvm/trunk/engines/sword25/package/packagemanager_script.cpp
    scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp
    scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h

Modified: scummvm/trunk/engines/sword25/package/packagemanager.h
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.h	2010-10-12 22:47:15 UTC (rev 53247)
+++ scummvm/trunk/engines/sword25/package/packagemanager.h	2010-10-12 22:47:38 UTC (rev 53248)
@@ -50,11 +50,12 @@
 #ifndef SWORD25_PACKAGE_MANAGER_H
 #define SWORD25_PACKAGE_MANAGER_H
 
-// Includes
 #include "sword25/kernel/common.h"
 #include "sword25/kernel/kernel.h"
 #include "sword25/kernel/service.h"
 
+#include "common/archive.h"
+
 namespace Sword25 {
 
 // Class definitions
@@ -79,41 +80,6 @@
 	};
 
 	/**
-	 * File search class
-	 *
-	 * These objects are created with BS_PackageManager::CreateSearch
-	 */
-	class FileSearch {
-	public:
-		virtual ~FileSearch() {};
-
-		/**
-		 * Returns the filename of the current file
-		 * @return          Returns the filename of the current file
-		 */
-		virtual Common::String GetCurFileName() = 0;
-		/**
-		 * Returns the type of the current file
-		 * @return          Returns the type of the current file
-		 * This is either BS_PackageManager::FT_FILE or BS_PackageManager::FT_DIRECTORY.
-		 */
-		virtual unsigned int GetCurFileType() = 0;
-		/**
-		 * Returns the size of the current file
-		 * @return          Returns the size of the current file
-		 * For directories, this value is always 0
-		 */
-		virtual unsigned int GetCurFileSize() = 0;
-		// Finds the next file
-		// Returns false if no more files are found.
-		/**
-		 * Finds the next file.
-		 * @return          Returns false if no other file fulfills the search criteria
-		*/
-		virtual bool NextFile() = 0;
-	};
-
-	/**
 	 * Mounts the contents of a package in the directory specified in the virtual directory tree.
 	 * @param FileName      The filename of the package to mount
 	 * @param MountPosition The directory name under which the package should be mounted
@@ -167,7 +133,7 @@
 	 * @return              Specifies a pointer to a BS_PackageManager::FileSearch object, or NULL if no file was found.
 	 * @remark              Do not forget to delete the object after use.
 	*/
-	virtual FileSearch *CreateSearch(const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
+	virtual int doSearch(Common::ArchiveMemberList &list, const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
 
 	/**
 	 * Returns a file's size

Modified: scummvm/trunk/engines/sword25/package/packagemanager_script.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager_script.cpp	2010-10-12 22:47:15 UTC (rev 53247)
+++ scummvm/trunk/engines/sword25/package/packagemanager_script.cpp	2010-10-12 22:47:38 UTC (rev 53248)
@@ -162,17 +162,18 @@
 	// Suche durchf\xFChren und die Namen aller gefundenen Dateien in die Ergebnistabelle einf\xFCgen.
 	// Als Indizes werden fortlaufende Nummern verwandt.
 	uint resultNr = 1;
-	BS_PackageManager::FileSearch *pFS = pPM->CreateSearch(filter, directory, type);
-	if (pFS) {
-		do {
+	Common::ArchiveMemberList list;
+	int numMatches;
+
+	numMatches = pPM->doSearch(list, filter, directory, type);
+	if (numMatches) {
+		for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
 			lua_pushnumber(L, resultNr);
-			lua_pushstring(L, pFS->GetCurFileName().c_str());
+			lua_pushstring(L, (*it)->getName().c_str());
 			lua_settable(L, -3);
 			resultNr++;
-		} while (pFS->NextFile());
+		}
 	}
-
-	delete(pFS);
 }
 
 // -----------------------------------------------------------------------------

Modified: scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp	2010-10-12 22:47:15 UTC (rev 53247)
+++ scummvm/trunk/engines/sword25/package/scummvmpackagemanager.cpp	2010-10-12 22:47:38 UTC (rev 53248)
@@ -110,6 +110,9 @@
 		zipFile->listMembers(files);
 		debug(0, "Capacity %d", files.size());
 
+		for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it)
+			debug(3, "%s", (*it)->getName().c_str());
+
 		_archiveList.push_back(new ArchiveEntry(zipFile, mountPosition));
 
 		return true;
@@ -206,45 +209,7 @@
 	return fileNode;
 }
 
-// -----------------------------------------------------------------------------
-// File find
-// -----------------------------------------------------------------------------
-
-class ArchiveFileSearch : public BS_PackageManager::FileSearch {
-public:
-	// Path must be normalised
-	ArchiveFileSearch(BS_PackageManager &packageManager, const Common::StringArray &foundFiles) :
-		_packageManager(packageManager),
-		_foundFiles(foundFiles),
-		_foundFilesIt(_foundFiles.begin()) {
-	}
-
-	virtual Common::String GetCurFileName() {
-		return *_foundFilesIt;
-	}
-
-	virtual unsigned int GetCurFileType() {
-		return _packageManager.GetFileType(*_foundFilesIt);
-	}
-
-	virtual unsigned int GetCurFileSize() {
-		return _packageManager.GetFileSize(*_foundFilesIt);
-	}
-
-	virtual bool NextFile() {
-		++_foundFilesIt;
-		return _foundFilesIt != _foundFiles.end();
-	}
-
-	BS_PackageManager                  &_packageManager;
-	Common::StringArray                 _foundFiles;
-	Common::StringArray::const_iterator _foundFilesIt;
-};
-
-// -----------------------------------------------------------------------------
-
-BS_PackageManager::FileSearch *BS_ScummVMPackageManager::CreateSearch(
-    const Common::String &filter, const Common::String &path, unsigned int typeFilter) {
+int BS_ScummVMPackageManager::doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, unsigned int typeFilter) {
 #if 0
 	Common::String normalizedPath = normalizePath(path, _currentDirectory);
 
@@ -267,8 +232,7 @@
 	return new ArchiveFileSearch(*this, nameList);
 #else
 	warning("STUB: BS_ScummVMPackageManager::CreateSearch(%s, %s, %d)", filter.c_str(), path.c_str(), typeFilter);
-	Common::StringArray nameList;
-	return new ArchiveFileSearch(*this, nameList);
+	return 0;
 #endif
 }
 

Modified: scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h
===================================================================
--- scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h	2010-10-12 22:47:15 UTC (rev 53247)
+++ scummvm/trunk/engines/sword25/package/scummvmpackagemanager.h	2010-10-12 22:47:38 UTC (rev 53248)
@@ -76,7 +76,7 @@
 	virtual Common::String GetCurrentDirectory();
 	virtual bool ChangeDirectory(const Common::String &directory);
 	virtual Common::String GetAbsolutePath(const Common::String &fileName);
-	virtual FileSearch *CreateSearch(const Common::String &filter, const Common::String &path, unsigned int typeFilter = FT_DIRECTORY | FT_FILE);
+	virtual int doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, unsigned int typeFilter = FT_DIRECTORY | FT_FILE);
 	virtual unsigned int GetFileSize(const Common::String &fileName);
 	virtual unsigned int GetFileType(const Common::String &fileName);
 	virtual bool FileExists(const Common::String &fileName);


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