aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sword25/kernel/service_ids.h4
-rw-r--r--engines/sword25/module.mk1
-rw-r--r--engines/sword25/package/packagemanager.cpp218
-rw-r--r--engines/sword25/package/packagemanager.h63
-rw-r--r--engines/sword25/package/scummvmpackagemanager.cpp253
-rw-r--r--engines/sword25/package/scummvmpackagemanager.h88
6 files changed, 256 insertions, 371 deletions
diff --git a/engines/sword25/kernel/service_ids.h b/engines/sword25/kernel/service_ids.h
index 9aafbd3e1d..c2d65d989f 100644
--- a/engines/sword25/kernel/service_ids.h
+++ b/engines/sword25/kernel/service_ids.h
@@ -50,7 +50,7 @@
namespace Sword25 {
Service *OpenGLGfx_CreateObject(Kernel *pKernel);
-Service *ScummVMPackageManager_CreateObject(Kernel *pKernel);
+Service *PackageManager_CreateObject(Kernel *pKernel);
Service *ScummVMInput_CreateObject(Kernel *pKernel);
Service *FMODExSound_CreateObject(Kernel *pKernel);
Service *LuaScriptEngine_CreateObject(Kernel *pKernel);
@@ -65,7 +65,7 @@ const BS_ServiceInfo BS_SERVICE_TABLE[] = {
// Example:
// BS_ServiceInfo("Superclass", "Service", CreateMethod)
BS_ServiceInfo("gfx", "opengl", OpenGLGfx_CreateObject),
- BS_ServiceInfo("package", "archiveFS", ScummVMPackageManager_CreateObject),
+ BS_ServiceInfo("package", "archiveFS", PackageManager_CreateObject),
BS_ServiceInfo("input", "winapi", ScummVMInput_CreateObject),
BS_ServiceInfo("sfx", "fmodex", FMODExSound_CreateObject),
BS_ServiceInfo("script", "lua", LuaScriptEngine_CreateObject),
diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk
index ba7a763088..3c620da965 100644
--- a/engines/sword25/module.mk
+++ b/engines/sword25/module.mk
@@ -66,7 +66,6 @@ MODULE_OBJS := \
math/walkregion.o \
package/packagemanager.o \
package/packagemanager_script.o \
- package/scummvmpackagemanager.o \
script/luabindhelper.o \
script/luacallback.o \
script/luascript.o \
diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp
index 92ba307b96..1b49eda5a4 100644
--- a/engines/sword25/package/packagemanager.cpp
+++ b/engines/sword25/package/packagemanager.cpp
@@ -34,21 +34,225 @@
#define BS_LOG_PREFIX "PACKAGEMANAGER"
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
+#include "common/archive.h"
+#include "common/config-manager.h"
+#include "common/str-array.h"
+#include "common/unzip.h"
#include "sword25/package/packagemanager.h"
-// -----------------------------------------------------------------------------
-
namespace Sword25 {
-PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel) {
+const char PATH_SEPARATOR = '/';
+
+static Common::String normalizePath(const Common::String &path, const Common::String &currentDirectory) {
+ Common::String wholePath = (path.size() >= 1 && path[0] == PATH_SEPARATOR) ? path : currentDirectory + PATH_SEPARATOR + path;
+
+ if (wholePath.size() == 0) {
+ // The path list has no elements, therefore the root directory is returned
+ return Common::String(PATH_SEPARATOR);
+ }
+
+ return Common::normalizePath(wholePath, PATH_SEPARATOR);
+}
+
+PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel),
+ _currentDirectory(PATH_SEPARATOR),
+ _rootFolder(ConfMan.get("path")) {
if (!_RegisterScriptBindings())
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
BS_LOGLN("Script bindings registered.");
}
+PackageManager::~PackageManager() {
+ // Free the package list
+ Common::List<ArchiveEntry *>::iterator i;
+ for (i = _archiveList.begin(); i != _archiveList.end(); ++i)
+ delete *i;
+
+}
+
+Service *PackageManager_CreateObject(Kernel *kernelPtr) {
+ return new PackageManager(kernelPtr);
+}
+
+/**
+ * Scans through the archive list for a specified file
+ */
+Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String &fileName) {
+ // Loop through checking each archive
+ Common::List<ArchiveEntry *>::iterator i;
+ for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
+ if (!fileName.hasPrefix((*i)->_mountPath)) {
+ // The mount path is in different subtree. Skipping
+ continue;
+ }
+
+ // Look into the archive for the desired file
+ Common::Archive *archiveFolder = (*i)->archive;
+
+ // Construct relative path
+ Common::String resPath(&fileName.c_str()[(*i)->_mountPath.size()]);
+
+ if (archiveFolder->hasFile(resPath)) {
+ return archiveFolder->getMember(resPath);
+ }
+ }
+
+ return Common::ArchiveMemberPtr();
+}
+
+bool PackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) {
+ Common::Archive *zipFile = Common::makeZipArchive(fileName);
+ if (zipFile == NULL) {
+ BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str());
+ return false;
+ } else {
+ BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str());
+ Common::ArchiveMemberList files;
+ 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;
+ }
+}
+
+bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
+ Common::FSNode directory(directoryName);
+ Common::Archive *folderArchive = new Common::FSDirectory(directory, 6);
+ if (!directory.exists() || (folderArchive == NULL)) {
+ BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str());
+ return false;
+ } else {
+ BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str());
+
+ Common::ArchiveMemberList files;
+ folderArchive->listMembers(files);
+ debug(0, "Capacity %d", files.size());
+
+ _archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));
+
+ return true;
+ }
+}
+
+byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) {
+ Common::SeekableReadStream *in;
+ Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ if (!fileNode)
+ return 0;
+ if (!(in = fileNode->createReadStream()))
+ return 0;
+
+ // If the filesize is desired, then output the size
+ if (fileSizePtr)
+ *fileSizePtr = in->size();
+
+ if (in->size() > 204800)
+ warning("UGLY: UGLY: Sucking >200kb file into memory (%d bytes)", in->size());
+
+ // Read the file
+ byte *buffer = new byte[in->size()];
+ int bytesRead = in->read(buffer, in->size());
+ delete in;
+
+ if (!bytesRead) {
+ delete buffer;
+ return NULL;
+ }
+
+ return buffer;
+}
+
+Common::SeekableReadStream *PackageManager::GetStream(const Common::String &fileName) {
+ Common::SeekableReadStream *in;
+ Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ if (!fileNode)
+ return 0;
+ if (!(in = fileNode->createReadStream()))
+ return 0;
+
+ return in;
+}
+
+Common::String PackageManager::GetCurrentDirectory() {
+ return _currentDirectory;
+}
+
+bool PackageManager::ChangeDirectory(const Common::String &directory) {
+ // Get the path elements for the file
+ _currentDirectory = normalizePath(directory, _currentDirectory);
+ return true;
+}
+
+Common::String PackageManager::GetAbsolutePath(const Common::String &fileName) {
+ return normalizePath(fileName, _currentDirectory);
+}
+
+uint PackageManager::GetFileSize(const Common::String &fileName) {
+ Common::SeekableReadStream *in;
+ Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ if (!fileNode)
+ return 0;
+ if (!(in = fileNode->createReadStream()))
+ return 0;
+
+ uint fileSize = in->size();
+
+ return fileSize;
+}
+
+uint PackageManager::GetFileType(const Common::String &fileName) {
+ warning("STUB: BS_PackageManager::GetFileType(%s)", fileName.c_str());
+
+ //return fileNode.isDirectory() ? BS_PackageManager::FT_DIRECTORY : BS_PackageManager::FT_FILE;
+ return PackageManager::FT_FILE;
+}
+
+bool PackageManager::FileExists(const Common::String &fileName) {
+ Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ return fileNode;
+}
+
+int PackageManager::doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter) {
+ Common::String normalizedFilter = normalizePath(filter, _currentDirectory);
+ int num = 0;
+
+ if (path.size() > 0)
+ warning("STUB: PackageManager::doSearch(<%s>, <%s>, %d)", filter.c_str(), path.c_str(), typeFilter);
+
+ // Loop through checking each archive
+ Common::List<ArchiveEntry *>::iterator i;
+ for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
+ Common::ArchiveMemberList memberList;
+
+ if (!normalizedFilter.hasPrefix((*i)->_mountPath)) {
+ // The mount path is in different subtree. Skipping
+ continue;
+ }
+
+ // Construct relative path
+ Common::String resFilter(&normalizedFilter.c_str()[(*i)->_mountPath.size()]);
+
+ if ((*i)->archive->listMatchingMembers(memberList, resFilter) == 0)
+ continue;
+
+ // Create a list of the matching names
+ for (Common::ArchiveMemberList::iterator it = memberList.begin(); it != memberList.end(); ++it) {
+ if (((typeFilter & PackageManager::FT_DIRECTORY) && (*it)->getName().hasSuffix("/")) ||
+ ((typeFilter & PackageManager::FT_FILE) && !(*it)->getName().hasSuffix("/"))) {
+ list.push_back(*it);
+ num++;
+ }
+ }
+ }
+
+ return num;
+}
+
} // End of namespace Sword25
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index fe1345ae68..1441c92606 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -50,12 +50,15 @@
#ifndef SWORD25_PACKAGE_MANAGER_H
#define SWORD25_PACKAGE_MANAGER_H
+#include "common/archive.h"
+#include "common/array.h"
+#include "common/fs.h"
+#include "common/str.h"
+
#include "sword25/kernel/common.h"
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/service.h"
-#include "common/archive.h"
-
namespace Sword25 {
// Class definitions
@@ -70,9 +73,29 @@ namespace Sword25 {
* have all files in packages.
*/
class PackageManager : public Service {
+private:
+ class ArchiveEntry {
+ public:
+ Common::Archive *archive;
+ Common::String _mountPath;
+
+ ArchiveEntry(Common::Archive *archive_, const Common::String &mountPath_):
+ archive(archive_), _mountPath(mountPath_) {
+ }
+ ~ArchiveEntry() {
+ delete archive;
+ }
+ };
+
+ Common::String _currentDirectory;
+ Common::FSNode _rootFolder;
+ Common::List<ArchiveEntry *> _archiveList;
+
+ Common::ArchiveMemberPtr GetArchiveMember(const Common::String &fileName);
+
public:
PackageManager(Kernel *pKernel);
- virtual ~PackageManager() {};
+ ~PackageManager();
enum FILE_TYPES {
FT_DIRECTORY = (1 << 0),
@@ -80,34 +103,34 @@ public:
};
/**
- * Mounts the contents of a package in the directory specified in the virtual directory tree.
+ * Mounts the contents of a package in the directory specified in the directory tree.
* @param FileName The filename of the package to mount
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
- virtual bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition) = 0;
+ bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition);
/**
- * Mounts the contents of a directory in the specified directory in the virtual directory tree.
+ * Mounts the contents of a directory in the specified directory in the directory tree.
* @param The name of the directory to mount
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
- virtual bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) = 0;
+ bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition);
/**
- * Downloads a file from the virtual directory tree
+ * Downloads a file from the directory tree
* @param FileName The filename of the file to load
* @param pFileSize Pointer to the variable that will contain the size of the loaded file. The deafult is NULL.
* @return Specifies a pointer to the loaded data of the file
* @remark The client must not forget to release the data of the file using BE_DELETE_A.
*/
- virtual byte *GetFile(const Common::String &FileName, uint *pFileSize = NULL) = 0;
+ byte *GetFile(const Common::String &FileName, uint *pFileSize = NULL);
/**
- * Returns a stream from file file from the virtual directory tree
+ * Returns a stream from file file from the directory tree
* @param FileName The filename of the file to load
* @return Pointer to the stream object
*/
- virtual Common::SeekableReadStream *GetStream(const Common::String &fileName) = 0;
+ Common::SeekableReadStream *GetStream(const Common::String &fileName);
/**
* Downloads an XML file and prefixes it with an XML Version key, since the XML files don't contain it,
* and it is required for ScummVM to correctly parse the XML.
@@ -136,22 +159,22 @@ public:
* If the path could not be determined, an empty string is returned.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual Common::String GetCurrentDirectory() = 0;
+ Common::String GetCurrentDirectory();
/**
* Changes the current directory.
* @param Directory The path to the new directory. The path can be relative.
* @return Returns true if the operation was successful, otherwise false.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual bool ChangeDirectory(const Common::String &Directory) = 0;
+ bool ChangeDirectory(const Common::String &Directory);
/**
- * Returns the absolute path to a file in the virtual directory tree.
+ * Returns the absolute path to a file in the directory tree.
* @param FileName The filename of the file whose absolute path is to be determined.
* These parameters may include both relative and absolute paths.
* @return Returns an absolute path to the given file.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual Common::String GetAbsolutePath(const Common::String &FileName) = 0;
+ Common::String GetAbsolutePath(const Common::String &FileName);
/**
* Creates a BS_PackageManager::FileSearch object to search for files
* @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
@@ -162,7 +185,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 int doSearch(Common::ArchiveMemberList &list, const Common::String &Filter, const Common::String &Path, uint TypeFilter = FT_DIRECTORY | FT_FILE) = 0;
+ int doSearch(Common::ArchiveMemberList &list, const Common::String &Filter, const Common::String &Path, uint TypeFilter = FT_DIRECTORY | FT_FILE);
/**
* Returns a file's size
@@ -170,7 +193,7 @@ public:
* @return The file size. If an error occurs, then 0xffffffff is returned.
* @remarks For files in packages, then uncompressed size is returned.
**/
- virtual uint GetFileSize(const Common::String &FileName) = 0;
+ uint GetFileSize(const Common::String &FileName);
/**
* Returns the type of a file.
@@ -179,19 +202,19 @@ public:
* or BS_PackageManager::FT_FILE).
* If the file was not found, then 0 is returned.
*/
- virtual uint GetFileType(const Common::String &FileName) = 0;
+ uint GetFileType(const Common::String &FileName);
/**
* Determines whether a file exists
* @param FileName The filename
* @return Returns true if the file exists, otherwise false.
*/
- virtual bool FileExists(const Common::String &FileName) = 0;
+ bool FileExists(const Common::String &FileName);
private:
bool _RegisterScriptBindings();
};
-} // ENd of namespace Sword25
+} // End of namespace Sword25
#endif
diff --git a/engines/sword25/package/scummvmpackagemanager.cpp b/engines/sword25/package/scummvmpackagemanager.cpp
deleted file mode 100644
index f58bb3960d..0000000000
--- a/engines/sword25/package/scummvmpackagemanager.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "common/archive.h"
-#include "common/config-manager.h"
-#include "common/str-array.h"
-#include "common/unzip.h"
-#include "sword25/package/scummvmpackagemanager.h"
-
-// -----------------------------------------------------------------------------
-
-#define BS_LOG_PREFIX "SCUMMVMPACKAGEMANAGER"
-
-namespace Sword25 {
-
-const char PATH_SEPARATOR = '/';
-
-static Common::String normalizePath(const Common::String &path, const Common::String &currentDirectory) {
- Common::String wholePath = (path.size() >= 1 && path[0] == PATH_SEPARATOR) ? path : currentDirectory + PATH_SEPARATOR + path;
-
- if (wholePath.size() == 0) {
- // The path list has no elements, therefore the root directory is returned
- return Common::String(PATH_SEPARATOR);
- }
-
- return Common::normalizePath(wholePath, PATH_SEPARATOR);
-}
-
-ScummVMPackageManager::ScummVMPackageManager(Kernel *kernelPtr) :
- PackageManager(kernelPtr),
- _currentDirectory(PATH_SEPARATOR),
- _rootFolder(ConfMan.get("path")) {
-}
-
-ScummVMPackageManager::~ScummVMPackageManager() {
- // Free the package list
- Common::List<ArchiveEntry *>::iterator i;
- for (i = _archiveList.begin(); i != _archiveList.end(); ++i)
- delete *i;
-
-}
-
-Service *ScummVMPackageManager_CreateObject(Kernel *kernelPtr) {
- return new ScummVMPackageManager(kernelPtr);
-}
-
-/**
- * Scans through the archive list for a specified file
- */
-Common::ArchiveMemberPtr ScummVMPackageManager::GetArchiveMember(const Common::String &fileName) {
- // Loop through checking each archive
- Common::List<ArchiveEntry *>::iterator i;
- for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
- if (!fileName.hasPrefix((*i)->_mountPath)) {
- // The mount path is in different subtree. Skipping
- continue;
- }
-
- // Look into the archive for the desired file
- Common::Archive *archiveFolder = (*i)->archive;
-
- // Construct relative path
- Common::String resPath(&fileName.c_str()[(*i)->_mountPath.size()]);
-
- if (archiveFolder->hasFile(resPath)) {
- return archiveFolder->getMember(resPath);
- }
- }
-
- return Common::ArchiveMemberPtr();
-}
-
-bool ScummVMPackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) {
- Common::Archive *zipFile = Common::makeZipArchive(fileName);
- if (zipFile == NULL) {
- BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str());
- return false;
- } else {
- BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str());
- Common::ArchiveMemberList files;
- 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;
- }
-}
-
-bool ScummVMPackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
- Common::FSNode directory(directoryName);
- Common::Archive *folderArchive = new Common::FSDirectory(directory, 6);
- if (!directory.exists() || (folderArchive == NULL)) {
- BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str());
- return false;
- } else {
- BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str());
-
- Common::ArchiveMemberList files;
- folderArchive->listMembers(files);
- debug(0, "Capacity %d", files.size());
-
- _archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));
-
- return true;
- }
-}
-
-byte *ScummVMPackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) {
- Common::SeekableReadStream *in;
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
- if (!fileNode)
- return 0;
- if (!(in = fileNode->createReadStream()))
- return 0;
-
- // If the filesize is desired, then output the size
- if (fileSizePtr)
- *fileSizePtr = in->size();
-
- if (in->size() > 204800)
- warning("UGLY: UGLY: Sucking >200kb file into memory (%d bytes)", in->size());
-
- // Read the file
- byte *buffer = new byte[in->size()];
- int bytesRead = in->read(buffer, in->size());
- delete in;
-
- if (!bytesRead) {
- delete buffer;
- return NULL;
- }
-
- return buffer;
-}
-
-Common::SeekableReadStream *ScummVMPackageManager::GetStream(const Common::String &fileName) {
- Common::SeekableReadStream *in;
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
- if (!fileNode)
- return 0;
- if (!(in = fileNode->createReadStream()))
- return 0;
-
- return in;
-}
-
-Common::String ScummVMPackageManager::GetCurrentDirectory() {
- return _currentDirectory;
-}
-
-bool ScummVMPackageManager::ChangeDirectory(const Common::String &directory) {
- // Get the path elements for the file
- _currentDirectory = normalizePath(directory, _currentDirectory);
- return true;
-}
-
-Common::String ScummVMPackageManager::GetAbsolutePath(const Common::String &fileName) {
- return normalizePath(fileName, _currentDirectory);
-}
-
-uint ScummVMPackageManager::GetFileSize(const Common::String &fileName) {
- Common::SeekableReadStream *in;
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
- if (!fileNode)
- return 0;
- if (!(in = fileNode->createReadStream()))
- return 0;
-
- uint fileSize = in->size();
-
- return fileSize;
-}
-
-uint ScummVMPackageManager::GetFileType(const Common::String &fileName) {
- warning("STUB: BS_ScummVMPackageManager::GetFileType(%s)", fileName.c_str());
-
- //return fileNode.isDirectory() ? BS_PackageManager::FT_DIRECTORY : BS_PackageManager::FT_FILE;
- return PackageManager::FT_FILE;
-}
-
-bool ScummVMPackageManager::FileExists(const Common::String &fileName) {
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
- return fileNode;
-}
-
-int ScummVMPackageManager::doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter) {
- Common::String normalizedFilter = normalizePath(filter, _currentDirectory);
- int num = 0;
-
- if (path.size() > 0)
- warning("STUB: BS_ScummVMPackageManager::doSearch(<%s>, <%s>, %d)", filter.c_str(), path.c_str(), typeFilter);
-
- // Loop through checking each archive
- Common::List<ArchiveEntry *>::iterator i;
- for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
- Common::ArchiveMemberList memberList;
-
- if (!normalizedFilter.hasPrefix((*i)->_mountPath)) {
- // The mount path is in different subtree. Skipping
- continue;
- }
-
- // Construct relative path
- Common::String resFilter(&normalizedFilter.c_str()[(*i)->_mountPath.size()]);
-
- if ((*i)->archive->listMatchingMembers(memberList, resFilter) == 0)
- continue;
-
- // Create a list of the matching names
- for (Common::ArchiveMemberList::iterator it = memberList.begin(); it != memberList.end(); ++it) {
- if (((typeFilter & PackageManager::FT_DIRECTORY) && (*it)->getName().hasSuffix("/")) ||
- ((typeFilter & PackageManager::FT_FILE) && !(*it)->getName().hasSuffix("/"))) {
- list.push_back(*it);
- num++;
- }
- }
- }
-
- return num;
-}
-
-} // End of namespace Sword25
-
diff --git a/engines/sword25/package/scummvmpackagemanager.h b/engines/sword25/package/scummvmpackagemanager.h
deleted file mode 100644
index bc8545d563..0000000000
--- a/engines/sword25/package/scummvmpackagemanager.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SWORD25_SCUMMVM_PACKAGE_MANAGER_H
-#define SWORD25_SCUMMVM_PACKAGE_MANAGER_H
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "common/archive.h"
-#include "common/array.h"
-#include "common/fs.h"
-#include "common/str.h"
-#include "sword25/kernel/common.h"
-#include "sword25/package/packagemanager.h"
-
-namespace Sword25 {
-
-// -----------------------------------------------------------------------------
-// Forward declarations
-// -----------------------------------------------------------------------------
-
-class Kernel;
-
-class ScummVMPackageManager : public PackageManager {
-private:
- class ArchiveEntry {
- public:
- Common::Archive *archive;
- Common::String _mountPath;
-
- ArchiveEntry(Common::Archive *archive_, const Common::String &mountPath_):
- archive(archive_), _mountPath(mountPath_) {
- }
- ~ArchiveEntry() {
- delete archive;
- }
- };
-
- Common::String _currentDirectory;
- Common::FSNode _rootFolder;
- Common::List<ArchiveEntry *> _archiveList;
-
- Common::ArchiveMemberPtr GetArchiveMember(const Common::String &fileName);
-
-public:
- ScummVMPackageManager(Kernel *kernelPtr);
- virtual ~ScummVMPackageManager();
-
- virtual bool LoadPackage(const Common::String &fileName, const Common::String &mountPosition);
- virtual bool LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition);
- virtual byte *GetFile(const Common::String &fileName, uint *fileSizePtr = 0);
- virtual Common::SeekableReadStream *GetStream(const Common::String &fileName);
- virtual Common::String GetCurrentDirectory();
- virtual bool ChangeDirectory(const Common::String &directory);
- virtual Common::String GetAbsolutePath(const Common::String &fileName);
- virtual int doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter = FT_DIRECTORY | FT_FILE);
- virtual uint GetFileSize(const Common::String &fileName);
- virtual uint GetFileType(const Common::String &fileName);
- virtual bool FileExists(const Common::String &fileName);
-};
-
-} // End of namespace Sword25
-
-#endif