aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-15 08:26:32 +0000
committerEugene Sandulenko2010-10-12 22:47:15 +0000
commit28d81a2a1c98dc082c54cf0770d11142910ec208 (patch)
tree2fdc74a9b38413df64aaeba3f42a819fe4e6005b /engines
parenteb191e3590823c2d29655fe3aaa77102ca7672cd (diff)
downloadscummvm-rg350-28d81a2a1c98dc082c54cf0770d11142910ec208.tar.gz
scummvm-rg350-28d81a2a1c98dc082c54cf0770d11142910ec208.tar.bz2
scummvm-rg350-28d81a2a1c98dc082c54cf0770d11142910ec208.zip
SWORD25: package manager. Style fixes. Cleanup
svn-id: r53247
Diffstat (limited to 'engines')
-rw-r--r--engines/sword25/package/packagemanager_script.cpp16
-rw-r--r--engines/sword25/package/scummvmpackagemanager.cpp78
-rw-r--r--engines/sword25/package/scummvmpackagemanager.h54
3 files changed, 63 insertions, 85 deletions
diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp
index 3719593e23..a0b2a392a7 100644
--- a/engines/sword25/package/packagemanager_script.cpp
+++ b/engines/sword25/package/packagemanager_script.cpp
@@ -146,29 +146,29 @@ static void SplitSearchPath(const Common::String &Path, Common::String &Director
// -----------------------------------------------------------------------------
-static void DoSearch(lua_State *L, const Common::String &Path, unsigned int Type) {
+static void DoSearch(lua_State *L, const Common::String &path, unsigned int type) {
BS_PackageManager *pPM = GetPM();
// Der Packagemanager-Service muss den Suchstring und den Pfad getrennt übergeben bekommen.
// Um die Benutzbarkeit zu verbessern sollen Skriptprogrammierer dieses als ein Pfad übergeben können.
// Daher muss der übergebene Pfad am letzten Slash aufgesplittet werden.
- Common::String Directory;
- Common::String Filter;
- SplitSearchPath(Path, Directory, Filter);
+ Common::String directory;
+ Common::String filter;
+ SplitSearchPath(path, directory, filter);
// Ergebnistable auf dem Lua-Stack erstellen
lua_newtable(L);
// Suche durchführen und die Namen aller gefundenen Dateien in die Ergebnistabelle einfügen.
// Als Indizes werden fortlaufende Nummern verwandt.
- unsigned int ResultNr = 1;
- BS_PackageManager::FileSearch *pFS = pPM->CreateSearch(Filter, Directory, Type);
+ uint resultNr = 1;
+ BS_PackageManager::FileSearch *pFS = pPM->CreateSearch(filter, directory, type);
if (pFS) {
do {
- lua_pushnumber(L, ResultNr);
+ lua_pushnumber(L, resultNr);
lua_pushstring(L, pFS->GetCurFileName().c_str());
lua_settable(L, -3);
- ResultNr++;
+ resultNr++;
} while (pFS->NextFile());
}
diff --git a/engines/sword25/package/scummvmpackagemanager.cpp b/engines/sword25/package/scummvmpackagemanager.cpp
index d21054e28a..50a869cc40 100644
--- a/engines/sword25/package/scummvmpackagemanager.cpp
+++ b/engines/sword25/package/scummvmpackagemanager.cpp
@@ -52,8 +52,8 @@ static Common::String normalizePath(const Common::String &path, const Common::St
return Common::normalizePath(wholePath, PATH_SEPARATOR);
}
-BS_ScummVMPackageManager::BS_ScummVMPackageManager(BS_Kernel *KernelPtr) :
- BS_PackageManager(KernelPtr),
+BS_ScummVMPackageManager::BS_ScummVMPackageManager(BS_Kernel *kernelPtr) :
+ BS_PackageManager(kernelPtr),
_currentDirectory(PATH_SEPARATOR),
_rootFolder(ConfMan.get("path")) {
}
@@ -65,8 +65,8 @@ BS_ScummVMPackageManager::~BS_ScummVMPackageManager() {
// -----------------------------------------------------------------------------
-BS_Service *BS_ScummVMPackageManager_CreateObject(BS_Kernel *KernelPtr) {
- return new BS_ScummVMPackageManager(KernelPtr);
+BS_Service *BS_ScummVMPackageManager_CreateObject(BS_Kernel *kernelPtr) {
+ return new BS_ScummVMPackageManager(kernelPtr);
}
// -----------------------------------------------------------------------------
@@ -74,20 +74,20 @@ BS_Service *BS_ScummVMPackageManager_CreateObject(BS_Kernel *KernelPtr) {
/**
* Scans through the archive list for a specified file
*/
-Common::ArchiveMemberPtr BS_ScummVMPackageManager::GetArchiveMember(const Common::String &FileName) {
+Common::ArchiveMemberPtr BS_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)) {
+ if (!fileName.hasPrefix((*i)->_mountPath)) {
// The mount path has more subfolder depth than the search entry, so skip it
continue;
}
// Look into the archive for the desired file
- Common::Archive *archiveFolder = (*i)->Archive;
+ Common::Archive *archiveFolder = (*i)->archive;
// Construct relative path
- Common::String resPath(&FileName.c_str()[(*i)->_mountPath.size()]);
+ Common::String resPath(&fileName.c_str()[(*i)->_mountPath.size()]);
if (archiveFolder->hasFile(resPath)) {
return archiveFolder->getMember(resPath);
@@ -99,18 +99,18 @@ Common::ArchiveMemberPtr BS_ScummVMPackageManager::GetArchiveMember(const Common
// -----------------------------------------------------------------------------
-bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const Common::String &MountPosition) {
- Common::Archive *zipFile = Common::makeZipArchive(FileName);
+bool BS_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());
+ 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());
+ 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());
- _archiveList.push_back(new ArchiveEntry(zipFile, MountPosition));
+ _archiveList.push_back(new ArchiveEntry(zipFile, mountPosition));
return true;
}
@@ -118,35 +118,35 @@ bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const
// -----------------------------------------------------------------------------
-bool BS_ScummVMPackageManager::LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) {
- Common::FSNode directory(DirectoryName);
+bool BS_ScummVMPackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
+ Common::FSNode directory(directoryName);
Common::Archive *folderArchive = new Common::FSDirectory(directory);
if (!directory.exists() || (folderArchive == NULL)) {
- BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", DirectoryName.c_str(), MountPosition.c_str());
+ 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());
- _archiveList.push_front(new ArchiveEntry(folderArchive, MountPosition));
+ BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str());
+ _archiveList.push_front(new ArchiveEntry(folderArchive, mountPosition));
return true;
}
}
// -----------------------------------------------------------------------------
-void *BS_ScummVMPackageManager::GetFile(const Common::String &FileName, unsigned int *FileSizePtr) {
+void *BS_ScummVMPackageManager::GetFile(const Common::String &fileName, unsigned int *fileSizePtr) {
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()))
return 0;
// If the filesize is desired, then output the size
- if (FileSizePtr)
- *FileSizePtr = in->size();
+ if (fileSizePtr)
+ *fileSizePtr = in->size();
- if (in->size() > 102400)
- warning("UGLY: UGLY: Sucking >100kb file into memory (%d bytes)", 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()];
@@ -171,15 +171,15 @@ bool BS_ScummVMPackageManager::ChangeDirectory(const Common::String &directory)
// -----------------------------------------------------------------------------
-Common::String BS_ScummVMPackageManager::GetAbsolutePath(const Common::String &FileName) {
- return normalizePath(FileName, _currentDirectory);
+Common::String BS_ScummVMPackageManager::GetAbsolutePath(const Common::String &fileName) {
+ return normalizePath(fileName, _currentDirectory);
}
// -----------------------------------------------------------------------------
-unsigned int BS_ScummVMPackageManager::GetFileSize(const Common::String &FileName) {
+unsigned int BS_ScummVMPackageManager::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()))
@@ -192,8 +192,8 @@ unsigned int BS_ScummVMPackageManager::GetFileSize(const Common::String &FileNam
// -----------------------------------------------------------------------------
-unsigned int BS_ScummVMPackageManager::GetFileType(const Common::String &FileName) {
- warning("STUB: BS_ScummVMPackageManager::GetFileType(%s)", FileName.c_str());
+unsigned int BS_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 BS_PackageManager::FT_FILE;
@@ -201,8 +201,8 @@ unsigned int BS_ScummVMPackageManager::GetFileType(const Common::String &FileNam
// -----------------------------------------------------------------------------
-bool BS_ScummVMPackageManager::FileExists(const Common::String &FileName) {
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(FileName, _currentDirectory));
+bool BS_ScummVMPackageManager::FileExists(const Common::String &fileName) {
+ Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
return fileNode;
}
@@ -213,9 +213,9 @@ bool BS_ScummVMPackageManager::FileExists(const Common::String &FileName) {
class ArchiveFileSearch : public BS_PackageManager::FileSearch {
public:
// Path must be normalised
- ArchiveFileSearch(BS_PackageManager &PackageManager, const Common::StringArray &FoundFiles) :
- _packageManager(PackageManager),
- _foundFiles(FoundFiles),
+ ArchiveFileSearch(BS_PackageManager &packageManager, const Common::StringArray &foundFiles) :
+ _packageManager(packageManager),
+ _foundFiles(foundFiles),
_foundFilesIt(_foundFiles.begin()) {
}
@@ -244,11 +244,11 @@ public:
// -----------------------------------------------------------------------------
BS_PackageManager::FileSearch *BS_ScummVMPackageManager::CreateSearch(
- const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter) {
+ const Common::String &filter, const Common::String &path, unsigned int typeFilter) {
#if 0
- Common::String NormalizedPath = normalizePath(Path, _currentDirectory);
+ Common::String normalizedPath = normalizePath(path, _currentDirectory);
- Common::FSNode folderNode = GetFSNode(Path);
+ Common::FSNode folderNode = GetFSNode(path);
if (!folderNode.exists() || !folderNode.isDirectory()) return NULL;
Common::Archive *folder = new Common::FSDirectory(folderNode);
@@ -266,7 +266,7 @@ BS_PackageManager::FileSearch *BS_ScummVMPackageManager::CreateSearch(
// Return a ArchiveFileSearch object that encapsulates the name list
return new ArchiveFileSearch(*this, nameList);
#else
- warning("STUB: BS_ScummVMPackageManager::CreateSearch(%s, %s, %d)", Filter.c_str(), Path.c_str(), TypeFilter);
+ warning("STUB: BS_ScummVMPackageManager::CreateSearch(%s, %s, %d)", filter.c_str(), path.c_str(), typeFilter);
Common::StringArray nameList;
return new ArchiveFileSearch(*this, nameList);
#endif
diff --git a/engines/sword25/package/scummvmpackagemanager.h b/engines/sword25/package/scummvmpackagemanager.h
index ffbe3654b4..cf772e2260 100644
--- a/engines/sword25/package/scummvmpackagemanager.h
+++ b/engines/sword25/package/scummvmpackagemanager.h
@@ -45,41 +45,18 @@ namespace Sword25 {
class BS_Kernel;
-// -----------------------------------------------------------------------------
-// Class definitions
-// -----------------------------------------------------------------------------
-
-struct PathElement {
-public:
- PathElement() { }
- PathElement(Common::String::const_iterator Begin, Common::String::const_iterator End) : m_Begin(Begin), m_End(End) {}
-
- Common::String::const_iterator GetBegin() const {
- return m_Begin;
- }
- Common::String::const_iterator GetEnd() const {
- return m_End;
- }
-
-private:
- Common::String::const_iterator m_Begin;
- Common::String::const_iterator m_End;
-};
-
-typedef Common::Array<PathElement *> PathElementArray;
-
class BS_ScummVMPackageManager : public BS_PackageManager {
private:
class ArchiveEntry {
public:
- Common::Archive *Archive;
+ Common::Archive *archive;
Common::String _mountPath;
- ArchiveEntry(Common::Archive *Archive_, const Common::String &MountPath_):
- Archive(Archive_), _mountPath(MountPath_) {
+ ArchiveEntry(Common::Archive *archive_, const Common::String &mountPath_):
+ archive(archive_), _mountPath(mountPath_) {
}
~ArchiveEntry() {
- delete Archive;
+ delete archive;
}
};
@@ -87,21 +64,22 @@ private:
Common::FSNode _rootFolder;
Common::List<ArchiveEntry *> _archiveList;
- Common::ArchiveMemberPtr GetArchiveMember(const Common::String &FileName);
+ Common::ArchiveMemberPtr GetArchiveMember(const Common::String &fileName);
+
public:
- BS_ScummVMPackageManager(BS_Kernel *KernelPtr);
+ BS_ScummVMPackageManager(BS_Kernel *kernelPtr);
virtual ~BS_ScummVMPackageManager();
- virtual bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition);
- virtual bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition);
- virtual void *GetFile(const Common::String &FileName, unsigned int *FileSizePtr = 0);
+ virtual bool LoadPackage(const Common::String &fileName, const Common::String &mountPosition);
+ virtual bool LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition);
+ virtual void *GetFile(const Common::String &fileName, unsigned int *fileSizePtr = 0);
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 unsigned int GetFileSize(const Common::String &FileName);
- virtual unsigned int GetFileType(const Common::String &FileName);
- virtual bool FileExists(const Common::String &FileName);
+ 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 unsigned int GetFileSize(const Common::String &fileName);
+ virtual unsigned int GetFileType(const Common::String &fileName);
+ virtual bool FileExists(const Common::String &fileName);
};
} // End of namespace Sword25