diff options
author | Jordi Vilalta Prat | 2008-01-27 19:47:41 +0000 |
---|---|---|
committer | Jordi Vilalta Prat | 2008-01-27 19:47:41 +0000 |
commit | 66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985 (patch) | |
tree | e27aadabecd8dd910884280e6559ff9c94c3d73c /backends/fs/ds | |
parent | 278857698dc7b1623096fe1ad12511dc4c886c7e (diff) | |
download | scummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.tar.gz scummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.tar.bz2 scummvm-rg350-66e9d4f5e8f35b28f8abd9ce53a0da4da3ce8985.zip |
Removed trailing spaces.
svn-id: r30664
Diffstat (limited to 'backends/fs/ds')
-rw-r--r-- | backends/fs/ds/ds-fs-factory.h | 10 | ||||
-rw-r--r-- | backends/fs/ds/ds-fs.cpp | 202 | ||||
-rw-r--r-- | backends/fs/ds/ds-fs.h | 44 |
3 files changed, 128 insertions, 128 deletions
diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h index a6a7bf6532..292a2baa69 100644 --- a/backends/fs/ds/ds-fs-factory.h +++ b/backends/fs/ds/ds-fs-factory.h @@ -30,20 +30,20 @@ /** * Creates DSFilesystemNode objects. - * + * * Parts of this class are documented in the base interface class, AbstractFilesystemFactory. */ -class DSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<DSFilesystemFactory> { +class DSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<DSFilesystemFactory> { public: typedef Common::String String; - + virtual AbstractFilesystemNode *makeRootFileNode() const; virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const; - + protected: DSFilesystemFactory() {}; - + private: friend class Common::Singleton<SingletonBaseType>; }; diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index bd8cc59008..6a1279e1e1 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -8,7 +8,7 @@ * 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 @@ -49,7 +49,7 @@ DSFileSystemNode::DSFileSystemNode() { _archive = (GBFS_FILE *) find_first_gbfs_file(scummdata); if (!_archive) consolePrintf("No GBFS archive found!\n"); }*/ - + if (!_zipFile) { _zipFile = new ZipFile(); } @@ -57,19 +57,19 @@ DSFileSystemNode::DSFileSystemNode() { DSFileSystemNode::DSFileSystemNode(const String& path) { // consolePrintf("--%s ",path.c_str()); - + char disp[128]; char* pathStr = (char *) path.c_str(); - + int lastSlash = 3; for (int r = 0; r < (int) strlen(pathStr) - 1; r++) { if (path[r] == '\\') { lastSlash = r; } } - + strcpy(disp, pathStr + lastSlash + 1); - + _displayName = String(disp); _path = path; // _isValid = true; @@ -78,13 +78,13 @@ DSFileSystemNode::DSFileSystemNode(const String& path) { if (!strncmp(pathStr, "ds:/", 4)) { pathStr += 4; } - + if (*pathStr == '\0') { _isValid = true; _isDirectory = true; return; } - + _zipFile->setAllFilesVisible(true); if (_zipFile->findFile(pathStr)) { _isValid = true; @@ -94,13 +94,13 @@ DSFileSystemNode::DSFileSystemNode(const String& path) { _isDirectory = false; } _zipFile->setAllFilesVisible(false); - + // consolePrintf("%s - Found: %d, Dir: %d\n", pathStr, _isValid, _isDirectory); } DSFileSystemNode::DSFileSystemNode(const String& path, bool isDir) { // consolePrintf("--%s ",path.c_str()); - + char disp[128]; char* pathStr = (char *) path.c_str(); int lastSlash = 3; @@ -109,14 +109,14 @@ DSFileSystemNode::DSFileSystemNode(const String& path, bool isDir) { lastSlash = r; } } - + strcpy(disp, pathStr + lastSlash + 1); - + _displayName = String(disp); _path = path; _isValid = true; _isDirectory = isDir; - + // consolePrintf("Found: %d, Dir: %d\n", _isValid, _isDirectory); } @@ -130,7 +130,7 @@ AbstractFilesystemNode *DSFileSystemNode::getChild(const Common::String& n) cons } else { return new DSFileSystemNode(_path + "\\" + n); } - + return NULL; } @@ -150,7 +150,7 @@ bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool _zipFile->changeDirectory(&temp[4]); } else { _zipFile->changeToRoot(); - + /* // This is the root dir, so add the RAM folder DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/ram"); dsfsn->_isDirectory = true; @@ -160,21 +160,21 @@ bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool } else { _zipFile->changeDirectory(temp); } - + if (_zipFile->restartFile()) { do { - char n[128]; + char n[128]; _zipFile->getFileName(n); - + // consolePrintf("file: %s\n", n); - if ( (_zipFile->isDirectory() && ((mode == FilesystemNode::kListDirectoriesOnly) || (mode == FilesystemNode::kListAll)) ) - || (!_zipFile->isDirectory() && ((mode == FilesystemNode::kListFilesOnly) || (mode == FilesystemNode::kListAll)) ) ) + if ( (_zipFile->isDirectory() && ((mode == FilesystemNode::kListDirectoriesOnly) || (mode == FilesystemNode::kListAll)) ) + || (!_zipFile->isDirectory() && ((mode == FilesystemNode::kListFilesOnly) || (mode == FilesystemNode::kListAll)) ) ) { DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/" + String(n), _zipFile->isDirectory()); dsfsn->_isDirectory = _zipFile->isDirectory(); dirList.push_back((dsfsn)); } - + } while (_zipFile->skipFile()); } @@ -185,10 +185,10 @@ AbstractFilesystemNode* DSFileSystemNode::getParent() const { // consolePrintf("parent\n"); DSFileSystemNode *p; - if (_path != "ds:/") { + if (_path != "ds:/") { char *path = (char *) _path.c_str(); int lastSlash = 4; - + for (int r = 4; r < (int) strlen((char *) path); r++) { if (path[r] == '\\') { lastSlash = r; @@ -218,7 +218,7 @@ GBAMPFileSystemNode::GBAMPFileSystemNode() { GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path) { // consolePrintf("'%s'",path.c_str()); - + char disp[128]; char* pathStr = (char *) path.c_str(); int lastSlash = 3; @@ -227,12 +227,12 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path) { lastSlash = r; } } - + strcpy(disp, pathStr + lastSlash + 1); char check[128]; int success; - + memset(check, 0, 128); if (strlen(pathStr) > 3) { strcpy(check, pathStr + 3); @@ -244,7 +244,7 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path) { success = FT_DIR; } // consolePrintf("Path: %s (%d)\n", check, success); - + _displayName = String(disp); _path = path; _isValid = success == FT_FILE; @@ -253,7 +253,7 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path) { GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path, bool isDirectory) { // consolePrintf("'%s'",path.c_str()); - + char disp[128]; char* pathStr = (char *) path.c_str(); int lastSlash = 3; @@ -262,7 +262,7 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path, bool isDirectory) { lastSlash = r; } } - + strcpy(disp, pathStr + lastSlash + 1); _displayName = String(disp); @@ -282,7 +282,7 @@ AbstractFilesystemNode *GBAMPFileSystemNode::getChild(const Common::String& n) c } else { return new DSFileSystemNode(_path + "\\" + n); } - + return NULL; } @@ -292,12 +292,12 @@ bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bo //TODO: honor the hidden flag enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 }; - + char temp[128], fname[256], *path, *pathTemp; strcpy(temp, _path.c_str()); - + path = temp + 3; - + pathTemp = path; while (*pathTemp) { if (*pathTemp == '\\') { @@ -308,37 +308,37 @@ bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bo consolePrintf("This dir: %s\n", path); FAT_chdir(path); - + int entryType = FAT_FindFirstFileLFN(fname); - + while (entryType != TYPE_NO_MORE) { - + if ( ((entryType == TYPE_DIR) && ((mode == FilesystemNode::kListDirectoriesOnly) || (mode == FilesystemNode::kListAll))) || ((entryType == TYPE_FILE) && ((mode == FilesystemNode::kListFilesOnly) || (mode == FilesystemNode::kListAll))) ) { GBAMPFileSystemNode* dsfsn; consolePrintf("Fname: %s\n", fname); - + if (strcmp(fname, ".") && strcmp(fname, "..")) { - + if (!strcmp(path, "/")) { dsfsn = new GBAMPFileSystemNode("mp:" + String(path) + String(fname), entryType == TYPE_DIR); } else { dsfsn = new GBAMPFileSystemNode("mp:" + String(path) + String("/") + String(fname), entryType == TYPE_DIR); } - + // dsfsn->_isDirectory = entryType == DIR; dirList.push_back((dsfsn)); } } else { // consolePrintf("Skipping %s\n", fname); } - + entryType = FAT_FindNextFileLFN(fname); } - + // consolePrintf("No more"); - + FAT_chdir("/"); return true; @@ -348,10 +348,10 @@ AbstractFilesystemNode* GBAMPFileSystemNode::getParent() const { // consolePrintf("parent\n"); GBAMPFileSystemNode *p; - if (_path != "mp:/") { + if (_path != "mp:/") { char *path = (char *) _path.c_str(); int lastSlash = 4; - + for (int r = 4; r < (int) strlen((char *) path); r++) { if (path[r] == '/') { lastSlash = r; @@ -381,14 +381,14 @@ FILE* std_fopen(const char* name, const char* mode) { inited = true; currentDir[0] = '\0'; } - + char* realName = (char *) name; - + // Remove file system prefix if ((name[0] == 'd') && (name[1] == 's') && (name[2] == ':') && (name[3] == '/')) { realName += 4; } - + if ((name[0] == 'm') && (name[1] == 'p') && (name[2] == ':') && (name[3] == '/')) { realName += 4; } @@ -398,15 +398,15 @@ FILE* std_fopen(const char* name, const char* mode) { if (DS::isGBAMPAvailable()) { FAT_chdir("/"); - + char* p = realName; while (*p) { if (*p == '\\') *p = '/'; p++; } - + FAT_FILE* result = FAT_fopen(realName, mode); - + if (result == 0) { // consolePrintf("Error code %d\n", result); //consolePrintf("Opening file %s\n", realName); @@ -414,16 +414,16 @@ FILE* std_fopen(const char* name, const char* mode) { // consolePrintf("Opened file %d\n", result); } // MT_memoryReport(); - + return (FILE *) result; } - + // Fail to open file for writing. It's in ROM! - + // Allocate a file handle int r = 0; while (handle[r].used) r++; - + if (strchr(mode, 'w')) { // consolePrintf("Writing %s\n", realName); handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, true); @@ -439,22 +439,22 @@ FILE* std_fopen(const char* name, const char* mode) { handle[r].size = handle[r].sramFile->getSize(); // consolePrintf("Found it"); return &handle[r]; - } + } // consolePrintf("Not in SRAM!"); char* data; - + ZipFile* zip = DSFileSystemNode::getZip(); if (!zip) { // consolePrintf("No zip yet!"); return NULL; } - + // Grab the data if it exists - + zip->setAllFilesVisible(true); - + if (currentDir[0] != 0) { char nameWithPath[128]; sprintf(nameWithPath, "%s\%s", currentDir, realName); @@ -462,16 +462,16 @@ FILE* std_fopen(const char* name, const char* mode) { } // consolePrintf("fopen(%s, %s)\n", realName, name); - + if (zip->findFile(realName)) { data = zip->getFile(); zip->setAllFilesVisible(false); - + // Allocate a file handle int r = 0; while (handle[r].used) r++; - - + + handle[r].used = true; handle[r].pos = 0; handle[r].data = data; @@ -512,26 +512,26 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { return bytes / size; } return numItems; - + /* int item = 0; u8* data = (u8 *) ptr; while ((item < numItems) && (!FAT_feof((FAT_FILE *) handle))) { - + int bytes = 0; while ((bytes < size) && (!FAT_feof((FAT_FILE *) handle))) { *data++ = FAT_fgetc((FAT_FILE *) handle); bytes++; } - + item++; - + } - + return item; */ int items = 0; - + //for (int r = 0; r < numItems; r++) { if (!std_feof(handle)) { /* for (int t = 0; t < size; t++) { @@ -540,7 +540,7 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { }*/ int left = size * numItems; int bytesRead = -1; - + while ((left > 0) && (!FAT_feof((FAT_FILE *) handle))) { int amount = left > 8192? 8192: left; // do { @@ -548,9 +548,9 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { /* if (bytesRead == 0) { consolePrintf("Pos:%d items:%d num:%d amount:%d read:%d\n", ftell(handle), items, numItems, amount, bytesRead); left++; - + int pos = ftell(handle); - + fseek(handle, 0, SEEK_SET); int c = getc(handle); fseek(handle, pos - 1024, SEEK_SET); @@ -562,21 +562,21 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { } while (bytesRead == 0); */ left -= bytesRead; - ptr = ((char *) (ptr)) + bytesRead; + ptr = ((char *) (ptr)) + bytesRead; } - + items = numItems - (left / size); // FAT_fread((void *) ptr, size, 1, ((int) (handle)) - 1); -// ptr = ((char *) (ptr)) + size; +// ptr = ((char *) (ptr)) + size; } // } - + // consolePrintf("...done %d \n", items) return items; } - + if (handle->sramFile) { int bytes = 0; int result = 1; @@ -586,9 +586,9 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { bytes += result; //consolePrintf("'%d',", ((char *) (ptr))[0]); } - + handle->pos += bytes; - + return bytes / size; } @@ -607,7 +607,7 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) { size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle) { if ((handle == stdin)) return 0; - + if ((handle == stderr) || (handle == stdout)) { // consolePrintf((char *) ptr); return size; @@ -618,18 +618,18 @@ size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle) { if (DS::isGBAMPAvailable()) { FAT_fwrite(((char *) (ptr)), size, numItems, (FAT_FILE *) handle); return numItems; - + int length = size * numItems; int pos = 0; - + while (pos < length) { int amount = length > 512? 512: length; - + FAT_fwrite(((char *) (ptr)) + pos, 1, amount, (FAT_FILE *) handle); length -= amount; - pos += amount; - } - + pos += amount; + } + return numItems; } @@ -651,7 +651,7 @@ bool std_feof(FILE* handle) { if (DS::isGBAMPAvailable()) { return FAT_feof((FAT_FILE *) handle); } - + if (handle->sramFile) { return handle->sramFile->eos(); } @@ -667,19 +667,19 @@ void std_fflush(FILE* handle) { char* std_fgets(char* str, int size, FILE* file) { // consolePrintf("fgets file=%d ", file); - + if (DS::isGBAMPAvailable()) { char* s = str; while ((*s++ = std_getc(file)) >= 32) { // consolePrintf("%d ", *s); } *s = 0; - + // consolePrintf("Read:%s\n", str); - + return str; } - + if (file->sramFile) { file->pos--; int p = -1; @@ -694,7 +694,7 @@ char* std_fgets(char* str, int size, FILE* file) { // consolePrintf("Read:%s\n", str); return str; } - + return NULL; } @@ -727,7 +727,7 @@ int std_fseek(FILE* handle, long int offset, int whence) { handle->pos = offset; break; } - + return 0; } @@ -740,7 +740,7 @@ int std_getc(FILE* handle) { if (DS::isGBAMPAvailable()) { char c; FAT_fread(&c, 1, 1, (FAT_FILE *) handle); - + return c; } @@ -763,15 +763,15 @@ void std_cwd(char* dir) { if ((strlen(dir) >= 4) && (dir[0] == 'm') && (dir[1] == 'p') && (dir[2] == ':') && (dir[3] == '/')) { realName += 4; } - + // consolePrintf("Real cwd:%d\n", realName); - + char* p = realName; while (*p) { if (*p == '\\') *p = '/'; p++; } - + // consolePrintf("Real cwd:%d\n", realName); FAT_chdir(realName); } else { @@ -784,13 +784,13 @@ void std_cwd(char* dir) { if (*p == '\\') *p = '/'; p++; } - + strcpy(currentDir, realName); if (*(currentDir + strlen(currentDir) - 1) == '/') { *(currentDir + strlen(currentDir) - 1) = '\0'; } // consolePrintf("CWD: %s\n", currentDir); - } + } } int std_ferror(FILE* handle) { @@ -801,11 +801,11 @@ int std_ferror(FILE* handle) { /** * Returns the last component of a given path. - * + * * Examples: * /foo/bar.txt would return /bar.txt * /foo/bar/ would return /bar/ - * + * * @param str String containing the path. * @return Pointer to the first char of the last component inside str. */ diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h index 0b5037d1a7..6b3452b53b 100644 --- a/backends/fs/ds/ds-fs.h +++ b/backends/fs/ds/ds-fs.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ - + #ifndef _DS_FS_H #define _DS_FS_H @@ -36,7 +36,7 @@ namespace DS { /** * Implementation of the ScummVM file system API. * This class is used when a Flash cart is in use. - * + * * Parts of this class are documented in the base interface class, AbstractFilesystemNode. */ class DSFileSystemNode : public AbstractFilesystemNode { @@ -50,33 +50,33 @@ protected: bool _isDirectory; bool _isValid; int _refCountVal; - + public: /** * Creates a DSFilesystemNode with the root node as path. */ DSFileSystemNode(); - + /** * Creates a DSFilesystemNode for a given path. - * + * * @param path String with the path the new node should point to. */ DSFileSystemNode(const String &path); - + /** * Creates a DSFilesystemNode for a given path. - * + * * @param path String with the path the new node should point to. * @param path true if path is a directory, false otherwise. */ DSFileSystemNode(const String& path, bool isDir); - + /** * Copy constructor. */ DSFileSystemNode(const DSFileSystemNode *node); - + virtual bool exists() const { return true; } //FIXME: this is just a stub virtual String getDisplayName() const { return _displayName; } virtual String getName() const { return _displayName; } @@ -84,7 +84,7 @@ public: virtual bool isDirectory() const { return _isDirectory; } virtual bool isReadable() const { return true; } //FIXME: this is just a stub virtual bool isWritable() const { return true; } //FIXME: this is just a stub - + /** * Returns a copy of this node. */ @@ -92,7 +92,7 @@ public: virtual AbstractFilesystemNode *getChild(const Common::String& name) const; virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly, bool hidden = false) const; virtual AbstractFilesystemNode *getParent() const; - + /** * Returns the zip file this node points to. * TODO: check this documentation. @@ -103,7 +103,7 @@ public: /** * Implementation of the ScummVM file system API. * This class is used when the GBAMP (GBA Movie Player) is used with a CompactFlash card. - * + * * Parts of this class are documented in the base interface class, AbstractFilesystemNode. */ class GBAMPFileSystemNode : public AbstractFilesystemNode { @@ -115,41 +115,41 @@ protected: bool _isDirectory; bool _isValid; int _refCountVal; - + public: /** * Creates a GBAMPFilesystemNode with the root node as path. */ GBAMPFileSystemNode(); - + /** * Creates a GBAMPFilesystemNode for a given path. - * + * * @param path String with the path the new node should point to. */ GBAMPFileSystemNode(const String &path); - + /** * Creates a DSFilesystemNode for a given path. - * + * * @param path String with the path the new node should point to. * @param path true if path is a directory, false otherwise. */ GBAMPFileSystemNode(const String &path, bool isDirectory); - + /** * Copy constructor. */ GBAMPFileSystemNode(const GBAMPFileSystemNode *node); - virtual bool exists() const { return _isValid || _isDirectory; } + virtual bool exists() const { return _isValid || _isDirectory; } virtual String getDisplayName() const { return _displayName; } virtual String getName() const { return _displayName; } virtual String getPath() const { return _path; } virtual bool isDirectory() const { return _isDirectory; } virtual bool isReadable() const { return true; } //FIXME: this is just a stub virtual bool isWritable() const { return true; } //FIXME: this is just a stub - + /** * Returns a copy of this node. */ @@ -164,7 +164,7 @@ struct fileHandle { bool used; char* data; int size; - + DSSaveFile* sramFile; }; @@ -177,7 +177,7 @@ struct fileHandle { #define stdin ((DS::fileHandle*) -3) #define FILE DS::fileHandle - + // Please do not remove any of these prototypes that appear not to be required. FILE* std_fopen(const char* name, const char* mode); void std_fclose(FILE* handle); |