aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/package
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-06 13:13:25 +0000
committerEugene Sandulenko2010-10-12 22:35:55 +0000
commit47904bc7b2992189bb554833f00a79ff0fea9fb8 (patch)
tree1cec51758c6741b970bd064fafee77607b9f884f /engines/sword25/package
parentca17def625154e5f758b797e4fc48c76b0566320 (diff)
downloadscummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.gz
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.tar.bz2
scummvm-rg350-47904bc7b2992189bb554833f00a79ff0fea9fb8.zip
SWORD25: Mass-astyle.
svn-id: r53222
Diffstat (limited to 'engines/sword25/package')
-rw-r--r--engines/sword25/package/packagemanager.cpp2
-rw-r--r--engines/sword25/package/packagemanager.h90
-rw-r--r--engines/sword25/package/packagemanager_script.cpp16
-rw-r--r--engines/sword25/package/scummvmpackagemanager.cpp48
-rw-r--r--engines/sword25/package/scummvmpackagemanager.h14
5 files changed, 87 insertions, 83 deletions
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
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index 1d6c71074f..92eb82f6e9 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -70,37 +70,37 @@ namespace Sword25 {
*/
class BS_PackageManager : public BS_Service {
public:
- BS_PackageManager(BS_Kernel* pKernel);
+ BS_PackageManager(BS_Kernel *pKernel);
virtual ~BS_PackageManager() {};
enum FILE_TYPES {
- FT_DIRECTORY = (1<<0),
- FT_FILE = (1<<1)
+ FT_DIRECTORY = (1 << 0),
+ FT_FILE = (1 << 1)
};
/**
* File search class
- *
+ *
* These objects are created with BS_PackageManager::CreateSearch
*/
class FileSearch {
public:
- virtual ~FileSearch(){};
+ virtual ~FileSearch() {};
/**
* Returns the filename of the current file
- * @return 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
+ * @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
+ * @return Returns the size of the current file
* For directories, this value is always 0
*/
virtual unsigned int GetCurFileSize() = 0;
@@ -108,79 +108,79 @@ public:
// Returns false if no more files are found.
/**
* Finds the next file.
- * @return Returns false if no other file fulfills the search criteria
+ * @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
- * @return Returns true if the mount was successful, otherwise false.
+ * @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;
/**
* Mounts the contents of a directory in the specified directory in the virtual 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.
+ * @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;
/**
* Downloads a file from the virtual 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.
+ * @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 void *GetFile(const Common::String &FileName, unsigned int *pFileSize = NULL) = 0;
/**
* Returns the path to the current directory.
- * @return Returns a string containing the path to the current directory.
+ * @return Returns a string containing the path to the current directory.
* If the path could not be determined, an empty string is returned.
- * @remark For cutting path elements '\' is used rather than '/' elements.
+ * @remark For cutting path elements '\' is used rather than '/' elements.
*/
- virtual Common::String GetCurrentDirectory() = 0;
+ virtual Common::String GetCurrentDirectory() = 0;
/**
* 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.
+ * @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;
+ virtual bool ChangeDirectory(const Common::String &Directory) = 0;
/**
* Returns the absolute path to a file in the virtual directory tree.
- * @param FileName The filename of the file whose absolute path is to be determined.
+ * @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.
+ * @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;
+ virtual Common::String GetAbsolutePath(const Common::String &FileName) = 0;
/**
* Creates a BS_PackageManager::FileSearch object to search for files
- * @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
- * @param Path Specifies the directory that should be searched.
- * @param TypeFilter A combination of flags BS_PackageManager::FT_DIRECTORY and BS_PackageManager::FT_FILE.
- * These flags indicate whether to search for files, directories, or both.
+ * @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
+ * @param Path Specifies the directory that should be searched.
+ * @param TypeFilter A combination of flags BS_PackageManager::FT_DIRECTORY and BS_PackageManager::FT_FILE.
+ * These flags indicate whether to search for files, directories, or both.
* The default is BS_PackageManager::FT_DIRECTORY | BS_PackageManager::FT_FILE
- * @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.
+ * @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;
/**
* Returns a file's size
- * @param FileName The filename
- * @return The file size. If an error occurs, then 0xffffffff is returned.
- * @remarks For files in packages, then uncompressed size is returned.
+ * @param FileName The filename
+ * @return The file size. If an error occurs, then 0xffffffff is returned.
+ * @remarks For files in packages, then uncompressed size is returned.
**/
virtual unsigned int GetFileSize(const Common::String &FileName) = 0;
/**
* Returns the type of a file.
- * @param FileName The filename
- * @return Returns the file type, either (BS_PackageManager::FT_DIRECTORY
+ * @param FileName The filename
+ * @return Returns the file type, either (BS_PackageManager::FT_DIRECTORY
* or BS_PackageManager::FT_FILE).
* If the file was not found, then 0 is returned.
*/
@@ -188,10 +188,10 @@ public:
/**
* Determines whether a file exists
- * @param FileName The filename
- * @return Returns true if the file exists, otherwise false.
+ * @param FileName The filename
+ * @return Returns true if the file exists, otherwise false.
*/
- virtual bool FileExists(const Common::String & FileName) = 0;
+ virtual bool FileExists(const Common::String &FileName) = 0;
private:
bool _RegisterScriptBindings();
diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp
index 48f869ed9e..803c346fdb 100644
--- a/engines/sword25/package/packagemanager_script.cpp
+++ b/engines/sword25/package/packagemanager_script.cpp
@@ -23,7 +23,7 @@
*
*/
-/*
+/*
* This code is based on Broken Sword 2.5 engine
*
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
@@ -50,7 +50,7 @@ using namespace Lua;
// -----------------------------------------------------------------------------
static BS_PackageManager *GetPM() {
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
BS_PackageManager *pPM = static_cast<BS_PackageManager *>(pKernel->GetService("package"));
BS_ASSERT(pPM);
@@ -135,7 +135,7 @@ static void SplitSearchPath(const Common::String &Path, Common::String &Director
const char *lastSlash = sPath + strlen(sPath) - 1;
while ((lastSlash >= sPath) && (*lastSlash != '/')) --lastSlash;
- if (lastSlash >= sPath) {
+ if (lastSlash >= sPath) {
Directory = "";
Filter = Path;
} else {
@@ -162,7 +162,7 @@ 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.
unsigned int ResultNr = 1;
- BS_PackageManager::FileSearch * pFS = pPM->CreateSearch(Filter, Directory, Type);
+ BS_PackageManager::FileSearch *pFS = pPM->CreateSearch(Filter, Directory, Type);
if (pFS) {
do {
lua_pushnumber(L, ResultNr);
@@ -195,7 +195,7 @@ static int GetFileAsString(lua_State *L) {
BS_PackageManager *pPM = GetPM();
unsigned int FileSize;
- void * FileData = pPM->GetFile(luaL_checkstring(L, 1), &FileSize);
+ void *FileData = pPM->GetFile(luaL_checkstring(L, 1), &FileSize);
if (FileData) {
lua_pushlstring(L, static_cast<char *>(FileData), FileSize);
delete FileData;
@@ -214,7 +214,7 @@ static int FileExists(lua_State *L) {
// -----------------------------------------------------------------------------
-static const char * PACKAGE_LIBRARY_NAME = "Package";
+static const char *PACKAGE_LIBRARY_NAME = "Package";
static const luaL_reg PACKAGE_FUNCTIONS[] = {
"LoadPackage", LoadPackage,
@@ -234,9 +234,9 @@ static const luaL_reg PACKAGE_FUNCTIONS[] = {
// -----------------------------------------------------------------------------
bool BS_PackageManager::_RegisterScriptBindings() {
- BS_Kernel * pKernel = BS_Kernel::GetInstance();
+ BS_Kernel *pKernel = BS_Kernel::GetInstance();
BS_ASSERT(pKernel);
- BS_ScriptEngine * pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
+ BS_ScriptEngine *pScript = static_cast<BS_ScriptEngine *>(pKernel->GetService("script"));
BS_ASSERT(pScript);
lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
diff --git a/engines/sword25/package/scummvmpackagemanager.cpp b/engines/sword25/package/scummvmpackagemanager.cpp
index fa2001dbed..43f16e1db6 100644
--- a/engines/sword25/package/scummvmpackagemanager.cpp
+++ b/engines/sword25/package/scummvmpackagemanager.cpp
@@ -94,12 +94,12 @@ static PathElementArray SeparatePath(const Common::String &Path, const Common::S
Common::String::const_iterator elementEnd = wholePath.begin() + nextseparatorPos;
if (elementEnd - elementBegin == 2 &&
- elementBegin[0] == NAVIGATION_CHARACTER &&
- elementBegin[1] == NAVIGATION_CHARACTER) {
+ elementBegin[0] == NAVIGATION_CHARACTER &&
+ elementBegin[1] == NAVIGATION_CHARACTER) {
// element is "..", therefore the previous path element should be removed
if (pathElements.size()) pathElements.pop_back();
} else if (elementEnd - elementBegin == 1 &&
- elementBegin[0] == NAVIGATION_CHARACTER) {
+ elementBegin[0] == NAVIGATION_CHARACTER) {
// element is ".", so we do nothing
} else {
// Normal elements get added to the list
@@ -114,7 +114,7 @@ static PathElementArray SeparatePath(const Common::String &Path, const Common::S
static Common::String NormalizePath(const Common::String &Path, const Common::String &CurrentDirectory) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(Path, CurrentDirectory);
+ PathElementArray pathElements = SeparatePath(Path, CurrentDirectory);
if (pathElements.size()) {
// The individual path elements are fitted together, separated by a directory
@@ -140,9 +140,9 @@ static Common::String NormalizePath(const Common::String &Path, const Common::St
// -----------------------------------------------------------------------------
BS_ScummVMPackageManager::BS_ScummVMPackageManager(BS_Kernel *KernelPtr) :
- BS_PackageManager(KernelPtr),
- _currentDirectory(PATH_SEPARATOR),
- _rootFolder(ConfMan.get("path")) {
+ BS_PackageManager(KernelPtr),
+ _currentDirectory(PATH_SEPARATOR),
+ _rootFolder(ConfMan.get("path")) {
}
// -----------------------------------------------------------------------------
@@ -152,8 +152,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);
}
// -----------------------------------------------------------------------------
@@ -177,11 +177,11 @@ Common::FSNode BS_ScummVMPackageManager::GetFSNode(const Common::String &FileNam
PathElementArray::iterator iEntry = i->MountPath.begin();
for (; iEntry != i->MountPath.end(); ++iEntry, ++iPath) {
- if (Common::String(iPath->GetBegin(), iPath->GetEnd()) ==
- Common::String(iEntry->GetBegin(), iEntry->GetEnd()))
+ if (Common::String(iPath->GetBegin(), iPath->GetEnd()) ==
+ Common::String(iEntry->GetBegin(), iEntry->GetEnd()))
break;
}
-
+
if (iEntry == i->MountPath.end()) {
// Look into the archive for the desired file
// Common::Archive *archiveFolder = i->Archive;
@@ -189,21 +189,21 @@ Common::FSNode BS_ScummVMPackageManager::GetFSNode(const Common::String &FileNam
// TODO: Loop through any folders in the archive
for (; iPath != pathElements.end(); ++iPath) {
- }
+ }
// Return the found node
return Common::FSNode();
}
}
- return Common::FSNode();
+ return Common::FSNode();
}
// -----------------------------------------------------------------------------
bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const Common::String &MountPosition) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
+ PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
Common::Archive *zipFile = Common::makeZipArchive(FileName);
if (zipFile == NULL) {
@@ -220,14 +220,14 @@ bool BS_ScummVMPackageManager::LoadPackage(const Common::String &FileName, const
bool BS_ScummVMPackageManager::LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition) {
// Get the path elements for the file
- PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
+ PathElementArray pathElements = SeparatePath(MountPosition, _currentDirectory);
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());
return false;
- } else {
+ } else {
BS_LOGLN("Directory '%s' mounted as '%s'.", DirectoryName.c_str(), MountPosition.c_str());
_archiveList.push_front(ArchiveEntry(folderArchive, pathElements));
return true;
@@ -241,14 +241,14 @@ void *BS_ScummVMPackageManager::GetFile(const Common::String &FileName, unsigned
Common::FSNode fileNode = GetFSNode(FileName);
if (!fileNode.exists()) return 0;
if (!f.open(fileNode)) return 0;
-
+
// If the filesize is desired, then output the size
if (FileSizePtr) *FileSizePtr = f.size();
// Read the file
byte *buffer = new byte[f.size()];
if (!f.read(buffer, f.size())) return 0;
-
+
f.close();
return buffer;
}
@@ -316,7 +316,7 @@ public:
_foundFilesIt(_foundFiles.begin()) {
}
- virtual Common::String GetCurFileName() {
+ virtual Common::String GetCurFileName() {
return *_foundFilesIt;
}
@@ -333,15 +333,15 @@ public:
return _foundFilesIt != _foundFiles.end();
}
- BS_PackageManager & _packageManager;
- Common::StringArray _foundFiles;
- Common::StringArray::const_iterator _foundFilesIt;
+ 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) {
+ const Common::String &Filter, const Common::String &Path, unsigned int TypeFilter) {
Common::String NormalizedPath = NormalizePath(Path, _currentDirectory);
Common::FSNode folderNode = GetFSNode(Path);
diff --git a/engines/sword25/package/scummvmpackagemanager.h b/engines/sword25/package/scummvmpackagemanager.h
index d279b7e8ad..a837f03bee 100644
--- a/engines/sword25/package/scummvmpackagemanager.h
+++ b/engines/sword25/package/scummvmpackagemanager.h
@@ -54,8 +54,12 @@ 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; }
+ 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;
@@ -72,7 +76,7 @@ private:
PathElementArray MountPath;
ArchiveEntry(Common::Archive *Archive_, const PathElementArray &MountPath_):
- Archive(Archive_), MountPath(MountPath_) {
+ Archive(Archive_), MountPath(MountPath_) {
}
~ArchiveEntry() {
delete Archive;
@@ -85,13 +89,13 @@ private:
Common::FSNode GetFSNode(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 Common::String GetCurrentDirectory();
+ 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);