aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-25 00:31:12 +0200
committerEinar Johan Trøan Sømåen2012-07-25 00:31:12 +0200
commit7521d0f26545381a740307d3a1d2f52e53462bfa (patch)
tree905e4bc84907d3ef221ccad35edd7a13bf0f52ae /engines
parent8be1e095fd6ab78f8f90633d254643f5bb45ffd4 (diff)
downloadscummvm-rg350-7521d0f26545381a740307d3a1d2f52e53462bfa.tar.gz
scummvm-rg350-7521d0f26545381a740307d3a1d2f52e53462bfa.tar.bz2
scummvm-rg350-7521d0f26545381a740307d3a1d2f52e53462bfa.zip
WINTERMUTE: Cleanup in BaseFileManager
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/base/base_file_manager.cpp62
-rw-r--r--engines/wintermute/base/base_file_manager.h6
2 files changed, 22 insertions, 46 deletions
diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp
index d54fe96854..3317b01c6f 100644
--- a/engines/wintermute/base/base_file_manager.cpp
+++ b/engines/wintermute/base/base_file_manager.cpp
@@ -31,14 +31,14 @@
#include "engines/wintermute/base/file/base_save_thumb_file.h"
#include "engines/wintermute/base/file/base_file_entry.h"
#include "engines/wintermute/base/file/base_package.h"
-#include "engines/wintermute/base/file/BPkgFile.h"
#include "engines/wintermute/base/file/base_resources.h"
+#include "engines/wintermute/base/file/BPkgFile.h"
#include "engines/wintermute/base/base_registry.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/file/dcpackage.h"
-#include "engines/wintermute/utils/utils.h"
#include "engines/wintermute/wintermute.h"
#include "common/str.h"
+#include "common/tokenizer.h"
#include "common/textconsole.h"
#include "common/util.h"
#include "common/config-manager.h"
@@ -96,7 +96,6 @@ bool BaseFileManager::cleanup() {
-#define MAX_FILE_SIZE 10000000
//////////////////////////////////////////////////////////////////////
byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) {
byte *buffer = NULL;
@@ -108,15 +107,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz
return NULL;
}
- /*
- if (File->GetSize() > MAX_FILE_SIZE) {
- _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE);
- CloseFile(File);
- return NULL;
- }
- */
-
-
buffer = new byte[file->size() + 1];
if (buffer == NULL) {
debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1);
@@ -207,39 +197,36 @@ bool BaseFileManager::initPaths() {
return STATUS_FAILED;
AnsiString pathList;
- int numPaths;
// single files paths
pathList = _gameRef->_registry->readString("Resource", "CustomPaths", "");
- numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';');
-
- for (int i = 0; i < numPaths; i++) {
- char *path = BaseUtils::strEntry(i, pathList.c_str(), ';');
- if (path && strlen(path) > 0) {
- error("BaseFileManager::initPaths - Game wants to add customPath: %s", path); // TODO
-// addPath(PATH_SINGLE, path);
+ Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";");
+// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';');
+ while (!entries->empty()) {
+ Common::String path = entries->nextToken();
+ if (path.size() > 0) {
+ error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO
+ // addPath(PATH_SINGLE, path);
}
- delete[] path;
- path = NULL;
}
-// addPath(PATH_SINGLE, ".\\");
+ delete entries;
+ entries = NULL;
// package files paths
const Common::FSNode gameData(ConfMan.get("path"));
addPath(PATH_PACKAGE, gameData);
pathList = _gameRef->_registry->readString("Resource", "PackagePaths", "");
- numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';');
-
- for (int i = 0; i < numPaths; i++) {
- char *path = BaseUtils::strEntry(i, pathList.c_str(), ';');
- if (path && strlen(path) > 0) {
- error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path); // TODO
-// addPath(PATH_PACKAGE, path);
+ entries = new Common::StringTokenizer(pathList, ";");
+ while (!entries->empty()) {
+ Common::String path = entries->nextToken();
+ if (path.size() > 0) {
+ error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO
+ // addPath(PATH_SINGLE, path);
}
- delete[] path;
- path = NULL;
}
+ delete entries;
+ entries = NULL;
Common::FSNode dataSubFolder = gameData.getChild("data");
if (dataSubFolder.exists()) {
@@ -296,17 +283,6 @@ bool BaseFileManager::registerPackages() {
return STATUS_OK;
}
-//////////////////////////////////////////////////////////////////////////
-/*bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) {
- Common::File *package = new Common::File();
- package->open(filename);
- if (!package->isOpen()) {
- debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Error opening package file '%s'. Ignoring.", filename.c_str());
- return STATUS_OK;
- }
- return registerPackage(package, filename);
-}*/
-
bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) {
uint32 absoluteOffset = 0;
bool boundToExe = false;
diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h
index cacdb8bf2d..776fc32df1 100644
--- a/engines/wintermute/base/base_file_manager.h
+++ b/engines/wintermute/base/base_file_manager.h
@@ -70,15 +70,15 @@ private:
bool registerPackages();
Common::SeekableReadStream *openFileRaw(const Common::String &filename);
Common::FSList _packagePaths;
-// Common::FSList _singlePaths;
bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset);
bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false);
-// bool registerPackage(const Common::String &filename, bool searchSignature = false);
- BaseGame *_gameRef;
Common::Array<BasePackage *> _packages;
Common::Array<Common::SeekableReadStream *> _openFiles;
Common::HashMap<Common::String, BaseFileEntry *> _files;
Common::HashMap<Common::String, BaseFileEntry *>::iterator _filesIter;
+ // This class is intentionally not a subclass of Base, as it needs to be used by
+ // the detector too, without launching the entire engine:
+ BaseGame *_gameRef;
};
} // end of namespace WinterMute