From a683a420a9e43705c972b5e74d55e319729e1a81 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 29 Jul 2010 19:53:02 +0000 Subject: SWORD25: Importing original sources svn-id: r53171 --- engines/sword25/package/packagemanager.cpp | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 engines/sword25/package/packagemanager.cpp (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp new file mode 100755 index 0000000000..ecee060d56 --- /dev/null +++ b/engines/sword25/package/packagemanager.cpp @@ -0,0 +1,36 @@ +// ----------------------------------------------------------------------------- +// This file is part of Broken Sword 2.5 +// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer +// +// Broken Sword 2.5 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. +// +// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// ----------------------------------------------------------------------------- + +#define BS_LOG_PREFIX "PACKAGEMANAGER" + +// ----------------------------------------------------------------------------- +// Includes +// ----------------------------------------------------------------------------- + +#include "packagemanager.h" + +// ----------------------------------------------------------------------------- + +BS_PackageManager::BS_PackageManager(BS_Kernel * pKernel) : BS_Service(pKernel) +{ + if (!_RegisterScriptBindings()) + BS_LOG_ERRORLN("Script bindings could not be registered."); + else + BS_LOGLN("Script bindings registered."); +} \ No newline at end of file -- cgit v1.2.3 From 65da804f583460739aec3bfe35b70310af1ee5a9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 29 Jul 2010 19:55:28 +0000 Subject: SWORD25: Path fixes for includes svn-id: r53180 --- engines/sword25/package/packagemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index ecee060d56..cb5b2b34a9 100755 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -23,7 +23,7 @@ // Includes // ----------------------------------------------------------------------------- -#include "packagemanager.h" +#include "sword25/package/packagemanager.h" // ----------------------------------------------------------------------------- -- cgit v1.2.3 From 293bf95c01f76c8d812a300eb038854f1246ab3d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 31 Jul 2010 09:53:02 +0000 Subject: SWORD25: Replacing headers with ScummVM ones plus original (C) svn-id: r53188 --- engines/sword25/package/packagemanager.cpp | 51 +++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) mode change 100755 => 100644 engines/sword25/package/packagemanager.cpp (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp old mode 100755 new mode 100644 index cb5b2b34a9..3d7e36a71e --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -1,21 +1,36 @@ -// ----------------------------------------------------------------------------- -// This file is part of Broken Sword 2.5 -// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer -// -// Broken Sword 2.5 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. -// -// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// ----------------------------------------------------------------------------- +/* 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$ + * + */ + +/* + * This code is based on Broken Sword 2.5 engine + * + * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer + * + * Licensed under GNU GPL v2 + * + */ #define BS_LOG_PREFIX "PACKAGEMANAGER" -- cgit v1.2.3 From ea29e41b86dd6efad5b044220505ded798b2503e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 Jul 2010 13:02:58 +0000 Subject: SWORD25: Reimplemented package manager for ScummVM using Common::Archive svn-id: r53194 --- engines/sword25/package/packagemanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 3d7e36a71e..2dc07cfae9 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -42,10 +42,13 @@ // ----------------------------------------------------------------------------- -BS_PackageManager::BS_PackageManager(BS_Kernel * pKernel) : BS_Service(pKernel) -{ +namespace Sword25 { + +BS_PackageManager::BS_PackageManager(BS_Kernel *pKernel) : BS_Service(pKernel) { if (!_RegisterScriptBindings()) BS_LOG_ERRORLN("Script bindings could not be registered."); else BS_LOGLN("Script bindings registered."); -} \ No newline at end of file +} + +} // End of namespace Sword25 -- cgit v1.2.3 From 47904bc7b2992189bb554833f00a79ff0fea9fb8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 6 Aug 2010 13:13:25 +0000 Subject: SWORD25: Mass-astyle. svn-id: r53222 --- engines/sword25/package/packagemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 2dc07cfae9..329061a6b3 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -23,7 +23,7 @@ * */ -/* +/* * This code is based on Broken Sword 2.5 engine * * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer -- cgit v1.2.3 From be44216e5c1d74879d7843215ce1cd3f488b4db8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 Aug 2010 12:57:47 +0000 Subject: SWORD25: eliminated BS_ prefix in all but kernel/ svn-id: r53259 --- engines/sword25/package/packagemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 329061a6b3..4bf25936bb 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -44,7 +44,7 @@ namespace Sword25 { -BS_PackageManager::BS_PackageManager(BS_Kernel *pKernel) : BS_Service(pKernel) { +PackageManager::PackageManager(BS_Kernel *pKernel) : BS_Service(pKernel) { if (!_RegisterScriptBindings()) BS_LOG_ERRORLN("Script bindings could not be registered."); else -- cgit v1.2.3 From b01994a53bbc96da907a4c28934e644184291017 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 Aug 2010 12:58:22 +0000 Subject: SWORD25: removed BS_ prefix from rest of the classes. The things which are intentionally left with the prefix: BS_LOG, BS_ASSERT, BS_Rect, BS_String. svn-id: r53261 --- engines/sword25/package/packagemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 4bf25936bb..92ba307b96 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -44,7 +44,7 @@ namespace Sword25 { -PackageManager::PackageManager(BS_Kernel *pKernel) : BS_Service(pKernel) { +PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel) { if (!_RegisterScriptBindings()) BS_LOG_ERRORLN("Script bindings could not be registered."); else -- cgit v1.2.3 From ccb1644568e2534bc2f67cf7fc8f3a9eff8971e7 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 14 Sep 2010 19:26:26 +0000 Subject: SWORD25: Got rid of ScummVMPackageManager svn-id: r53353 --- engines/sword25/package/packagemanager.cpp | 218 ++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 7 deletions(-) (limited to 'engines/sword25/package/packagemanager.cpp') 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 ¤tDirectory) { + 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::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::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::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 -- cgit v1.2.3 From 3e84d4fe73ac36bcfb36bbe8a26ce99ab71e92db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 20 Sep 2010 09:38:53 +0000 Subject: SWORD25: Implemented thumbnail loading for savegame list svn-id: r53374 --- engines/sword25/package/packagemanager.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 1b49eda5a4..4cea4f578d 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -36,8 +36,11 @@ #include "common/archive.h" #include "common/config-manager.h" +#include "common/savefile.h" #include "common/str-array.h" +#include "common/system.h" #include "common/unzip.h" +#include "sword25/kernel/filesystemutil.h" #include "sword25/package/packagemanager.h" namespace Sword25 { @@ -142,7 +145,29 @@ bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, } byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) { + const Common::String B25S_EXTENSION(".b25s"); Common::SeekableReadStream *in; + + if (fileName.hasSuffix(B25S_EXTENSION)) { + // Savegame loading logic + Common::SaveFileManager *sfm = g_system->getSavefileManager(); + Common::InSaveFile *file = sfm->openForLoading( + FileSystemUtil::GetInstance().GetPathFilename(fileName)); + if (!file) { + BS_LOG_ERRORLN("Could not load savegame \"%s\".", fileName.c_str()); + return 0; + } + + if (*fileSizePtr) + *fileSizePtr = file->size(); + + byte *buffer = new byte[file->size()]; + file->read(buffer, file->size()); + + delete file; + return buffer; + } + Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory)); if (!fileNode) return 0; -- cgit v1.2.3 From 2143afde6cfd3ee3f068861589fd45212ef755de Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 25 Sep 2010 19:48:05 +0000 Subject: SWORD25: Add support for language patch svn-id: r53377 --- engines/sword25/package/packagemanager.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 4cea4f578d..801f695f15 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -106,6 +106,8 @@ Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String & } bool PackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) { + debug(0, "LoadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str()); + 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()); @@ -119,7 +121,7 @@ bool PackageManager::LoadPackage(const Common::String &fileName, const Common::S 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)); + _archiveList.push_front(new ArchiveEntry(zipFile, mountPosition)); return true; } @@ -271,7 +273,18 @@ int PackageManager::doSearch(Common::ArchiveMemberList &list, const Common::Stri 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); + + // Do not add duplicate files + bool found = false; + for (Common::ArchiveMemberList::iterator it1 = list.begin(); it1 != list.end(); ++it1) { + if ((*it1)->getName() == (*it)->getName()) { + found = true; + break; + } + } + + if (!found) + list.push_back(*it); num++; } } -- cgit v1.2.3 From 8582c1ad5770b6385381f524a4610934d115cd88 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 25 Sep 2010 19:48:26 +0000 Subject: SWORD25: Enforse code naming conventions in PackageManager and Sword25Engine svn-id: r53380 --- engines/sword25/package/packagemanager.cpp | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 801f695f15..18b2453d6d 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -61,7 +61,7 @@ static Common::String normalizePath(const Common::String &path, const Common::St PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel), _currentDirectory(PATH_SEPARATOR), _rootFolder(ConfMan.get("path")) { - if (!_RegisterScriptBindings()) + if (!registerScriptBindings()) BS_LOG_ERRORLN("Script bindings could not be registered."); else BS_LOGLN("Script bindings registered."); @@ -82,7 +82,7 @@ Service *PackageManager_CreateObject(Kernel *kernelPtr) { /** * Scans through the archive list for a specified file */ -Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String &fileName) { +Common::ArchiveMemberPtr PackageManager::getArchiveMember(const Common::String &fileName) { // Loop through checking each archive Common::List::iterator i; for (i = _archiveList.begin(); i != _archiveList.end(); ++i) { @@ -105,8 +105,8 @@ Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String & return Common::ArchiveMemberPtr(); } -bool PackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) { - debug(0, "LoadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str()); +bool PackageManager::loadPackage(const Common::String &fileName, const Common::String &mountPosition) { + debug(3, "loadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str()); Common::Archive *zipFile = Common::makeZipArchive(fileName); if (zipFile == NULL) { @@ -116,7 +116,7 @@ bool PackageManager::LoadPackage(const Common::String &fileName, const Common::S 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()); + debug(3, "Capacity %d", files.size()); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) debug(3, "%s", (*it)->getName().c_str()); @@ -127,7 +127,7 @@ bool PackageManager::LoadPackage(const Common::String &fileName, const Common::S } } -bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) { +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)) { @@ -146,7 +146,7 @@ bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, } } -byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) { +byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) { const Common::String B25S_EXTENSION(".b25s"); Common::SeekableReadStream *in; @@ -170,7 +170,7 @@ byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) return buffer; } - Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory)); + Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory)); if (!fileNode) return 0; if (!(in = fileNode->createReadStream())) @@ -196,9 +196,9 @@ byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) return buffer; } -Common::SeekableReadStream *PackageManager::GetStream(const Common::String &fileName) { +Common::SeekableReadStream *PackageManager::getStream(const Common::String &fileName) { Common::SeekableReadStream *in; - Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory)); + Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory)); if (!fileNode) return 0; if (!(in = fileNode->createReadStream())) @@ -207,23 +207,23 @@ Common::SeekableReadStream *PackageManager::GetStream(const Common::String &file return in; } -Common::String PackageManager::GetCurrentDirectory() { +Common::String PackageManager::getCurrentDirectory() { return _currentDirectory; } -bool PackageManager::ChangeDirectory(const Common::String &directory) { +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) { +Common::String PackageManager::getAbsolutePath(const Common::String &fileName) { return normalizePath(fileName, _currentDirectory); } -uint PackageManager::GetFileSize(const Common::String &fileName) { +uint PackageManager::getFileSize(const Common::String &fileName) { Common::SeekableReadStream *in; - Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory)); + Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory)); if (!fileNode) return 0; if (!(in = fileNode->createReadStream())) @@ -234,15 +234,15 @@ uint PackageManager::GetFileSize(const Common::String &fileName) { return fileSize; } -uint PackageManager::GetFileType(const Common::String &fileName) { +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)); +bool PackageManager::fileExists(const Common::String &fileName) { + Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory)); return fileNode; } -- cgit v1.2.3 From 1855cee5e37009e51f3c319aba5888ca57061cb8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 25 Sep 2010 19:48:29 +0000 Subject: SWORD25: Loading >200kb file in memory is no more ugly svn-id: r53381 --- engines/sword25/package/packagemanager.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'engines/sword25/package/packagemanager.cpp') diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 18b2453d6d..063844f3ba 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -180,9 +180,6 @@ byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) 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()); -- cgit v1.2.3