aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-15 08:50:03 +0000
committerEugene Sandulenko2010-10-12 22:47:38 +0000
commit0cdab788ae651f428d5f6b7e1ee24b26c4814eff (patch)
tree03f92634ddb02f653aeb5177ef598bb00beb8c1c
parent28d81a2a1c98dc082c54cf0770d11142910ec208 (diff)
downloadscummvm-rg350-0cdab788ae651f428d5f6b7e1ee24b26c4814eff.tar.gz
scummvm-rg350-0cdab788ae651f428d5f6b7e1ee24b26c4814eff.tar.bz2
scummvm-rg350-0cdab788ae651f428d5f6b7e1ee24b26c4814eff.zip
SWORD25: Changed signature of FS searching method. Cleanup.
svn-id: r53248
-rw-r--r--engines/sword25/package/packagemanager.h40
-rw-r--r--engines/sword25/package/packagemanager_script.cpp15
-rw-r--r--engines/sword25/package/scummvmpackagemanager.cpp46
-rw-r--r--engines/sword25/package/scummvmpackagemanager.h2
4 files changed, 17 insertions, 86 deletions
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index 92eb82f6e9..73601b1f68 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -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 @@ public:
};
/**
- * 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 @@ public:
* @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
diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp
index a0b2a392a7..83d0ae7580 100644
--- a/engines/sword25/package/packagemanager_script.cpp
+++ b/engines/sword25/package/packagemanager_script.cpp
@@ -162,17 +162,18 @@ static void DoSearch(lua_State *L, const Common::String &path, unsigned int type
// Suche durchführen und die Namen aller gefundenen Dateien in die Ergebnistabelle einfügen.
// 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);
}
// -----------------------------------------------------------------------------
diff --git a/engines/sword25/package/scummvmpackagemanager.cpp b/engines/sword25/package/scummvmpackagemanager.cpp
index 50a869cc40..d6d840b2e3 100644
--- a/engines/sword25/package/scummvmpackagemanager.cpp
+++ b/engines/sword25/package/scummvmpackagemanager.cpp
@@ -110,6 +110,9 @@ bool BS_ScummVMPackageManager::LoadPackage(const Common::String &fileName, const
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 @@ bool BS_ScummVMPackageManager::FileExists(const Common::String &fileName) {
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 @@ BS_PackageManager::FileSearch *BS_ScummVMPackageManager::CreateSearch(
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
}
diff --git a/engines/sword25/package/scummvmpackagemanager.h b/engines/sword25/package/scummvmpackagemanager.h
index cf772e2260..e15cedade4 100644
--- a/engines/sword25/package/scummvmpackagemanager.h
+++ b/engines/sword25/package/scummvmpackagemanager.h
@@ -76,7 +76,7 @@ public:
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);