aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/ds
diff options
context:
space:
mode:
authorMax Horn2007-09-18 20:02:04 +0000
committerMax Horn2007-09-18 20:02:04 +0000
commitc3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac (patch)
tree17b2ba9f45743d2cf8f8e5faa6c9511e213f15f3 /backends/fs/ds
parent5c08cb1bcf84828cc93114fadbc89dd6f9909d06 (diff)
parent1dc13a641dd82825334e81bb3eb3b4ebd69d2552 (diff)
downloadscummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.gz
scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.tar.bz2
scummvm-rg350-c3d3aebe87d16d4fc3b7ac8581b99fb97241c9ac.zip
Patch #1768757: Merge fsnode-gsoc into trunk (MAJOR change, will break compilation on some ports)
svn-id: r28944
Diffstat (limited to 'backends/fs/ds')
-rw-r--r--backends/fs/ds/ds-fs-factory.cpp53
-rw-r--r--backends/fs/ds/ds-fs-factory.h51
-rw-r--r--backends/fs/ds/ds-fs.cpp234
-rw-r--r--backends/fs/ds/ds-fs.h119
4 files changed, 268 insertions, 189 deletions
diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp
new file mode 100644
index 0000000000..0de284d1eb
--- /dev/null
+++ b/backends/fs/ds/ds-fs-factory.cpp
@@ -0,0 +1,53 @@
+/* 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$
+ */
+
+#include "backends/fs/ds/ds-fs-factory.h"
+#include "backends/fs/ds/ds-fs.cpp"
+#include "dsmain.h" //for the isGBAMPAvailable() function
+
+DECLARE_SINGLETON(DSFilesystemFactory);
+
+AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const {
+ if (DS::isGBAMPAvailable()) {
+ return new DS::GBAMPFileSystemNode();
+ } else {
+ return new DS::DSFileSystemNode();
+ }
+}
+
+AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const {
+ if (DS::isGBAMPAvailable()) {
+ return new DS::GBAMPFileSystemNode();
+ } else {
+ return new DS::DSFileSystemNode();
+ }
+}
+
+AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const String &path) const {
+ if (DS::isGBAMPAvailable()) {
+ return new DS::GBAMPFileSystemNode(path);
+ } else {
+ return new DS::DSFileSystemNode(path);
+ }
+}
diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h
new file mode 100644
index 0000000000..a6a7bf6532
--- /dev/null
+++ b/backends/fs/ds/ds-fs-factory.h
@@ -0,0 +1,51 @@
+/* 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$
+ */
+
+#ifndef DS_FILESYSTEM_FACTORY_H
+#define DS_FILESYSTEM_FACTORY_H
+
+#include "common/singleton.h"
+#include "backends/fs/abstract-fs-factory.h"
+
+/**
+ * Creates DSFilesystemNode objects.
+ *
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+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>;
+};
+
+#endif /*DS_FILESYSTEM_FACTORY_H*/
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index abfd0397c6..11d373ea1e 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -20,24 +20,18 @@
*
*/
-
#include "stdafx.h"
#include "str.h"
-#include "fs.h"
#include "common/util.h"
//#include <NDS/ARM9/console.h> //basic print funcionality
#include "ds-fs.h"
#include "dsmain.h"
#include "gba_nds_fat.h"
-
namespace DS {
-
-
-
//////////////////////////////////////////////////////////////
-// DSFileSystemNode - Flash ROM file system using Zip files
+// DSFileSystemNode - Flash ROM file system using Zip files //
//////////////////////////////////////////////////////////////
ZipFile* DSFileSystemNode::_zipFile = NULL;
@@ -66,7 +60,6 @@ DSFileSystemNode::DSFileSystemNode(const String& path) {
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] == '\\') {
@@ -81,13 +74,10 @@ DSFileSystemNode::DSFileSystemNode(const String& path) {
// _isValid = true;
// _isDirectory = false;
-
-
if (!strncmp(pathStr, "ds:/", 4)) {
pathStr += 4;
}
-
if (*pathStr == '\0') {
_isValid = true;
_isDirectory = true;
@@ -130,35 +120,10 @@ DSFileSystemNode::DSFileSystemNode(const String& path, bool isDir) {
}
DSFileSystemNode::DSFileSystemNode(const DSFileSystemNode* node) {
-
+ //TODO: not implemented?
}
-AbstractFilesystemNode* DSFileSystemNode::parent() const {
-// consolePrintf("parent\n");
- DSFileSystemNode *p;
-
- 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;
- }
- }
-
- p = new DSFileSystemNode(String(path, lastSlash));
- ((DSFileSystemNode *) (p))->_isDirectory = true;
- } else {
- p = new DSFileSystemNode();
- }
-
- return p;
-
-}
-
-
-AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& n) const {
+AbstractFilesystemNode *DSFileSystemNode::getChild(const Common::String& n) const {
if (_path.lastChar() == '\\') {
return new DSFileSystemNode(_path + n);
} else {
@@ -168,14 +133,12 @@ AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& n) const {
return NULL;
}
-
-bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const {
+bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool hidden) const {
// consolePrintf("Listdir\n");
-
-
// consolePrintf("Directory\n");
-
+ //TODO: honor the hidden flag
+
char temp[128];
strcpy(temp, _path.c_str());
@@ -190,14 +153,13 @@ bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const {
/* // This is the root dir, so add the RAM folder
DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/ram");
dsfsn->_isDirectory = true;
- dirList->push_back(wrap(dsfsn));*/
+ dirList->push_back(wrap(dsfsn));
+*/
}
} else {
_zipFile->changeDirectory(temp);
}
-
-
if (_zipFile->restartFile()) {
do {
char n[128];
@@ -218,12 +180,32 @@ bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const {
return true;
}
+AbstractFilesystemNode* DSFileSystemNode::getParent() const {
+// consolePrintf("parent\n");
+ DSFileSystemNode *p;
+
+ 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;
+ }
+ }
+ p = new DSFileSystemNode(String(path, lastSlash));
+ ((DSFileSystemNode *) (p))->_isDirectory = true;
+ } else {
+ p = new DSFileSystemNode();
+ }
+ return p;
+}
-/////////////////////////////////////////////////////////////////////////
-// GBAMPFileSystemNode - File system using GBA Movie Player and CF card
-/////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+// GBAMPFileSystemNode - File system using GBA Movie Player and CF card //
+//////////////////////////////////////////////////////////////////////////
GBAMPFileSystemNode::GBAMPFileSystemNode() {
_displayName = "mp:/";
@@ -290,35 +272,10 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const String& path, bool isDirectory) {
GBAMPFileSystemNode::GBAMPFileSystemNode(const GBAMPFileSystemNode* node) {
-
+ //TODO: not implemented?
}
-
-AbstractFilesystemNode* GBAMPFileSystemNode::parent() const {
-// consolePrintf("parent\n");
- GBAMPFileSystemNode *p;
-
- 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;
- }
- }
-
- p = new GBAMPFileSystemNode(String(path, lastSlash));
- p->_isDirectory = true;
- } else {
- p = new GBAMPFileSystemNode();
- }
-
- return p;
-
-}
-
-AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& n) const {
+AbstractFilesystemNode *GBAMPFileSystemNode::getChild(const Common::String& n) const {
if (_path.lastChar() == '\\') {
return new DSFileSystemNode(_path + n);
} else {
@@ -328,9 +285,11 @@ AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& n) cons
return NULL;
}
-bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const {
+bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bool hidden) const {
// consolePrintf("Listdir\n");
+ //TODO: honor the hidden flag
+
enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 };
char temp[128], fname[128], *path, *pathTemp;
@@ -346,7 +305,6 @@ bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const
pathTemp++;
}
-
// consolePrintf("This dir: %s\n", path);
FAT_chdir(path);
@@ -369,8 +327,6 @@ bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const
// dsfsn->_isDirectory = entryType == DIR;
dirList.push_back((dsfsn));
}
-
-
} else {
// consolePrintf("Skipping %s\n", fname);
}
@@ -385,6 +341,28 @@ bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const
return true;
}
+AbstractFilesystemNode* GBAMPFileSystemNode::getParent() const {
+// consolePrintf("parent\n");
+ GBAMPFileSystemNode *p;
+
+ 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;
+ }
+ }
+
+ p = new GBAMPFileSystemNode(String(path, lastSlash));
+ p->_isDirectory = true;
+ } else {
+ p = new GBAMPFileSystemNode();
+ }
+
+ return p;
+}
// Stdio replacements
#define MAX_FILE_HANDLES 32
@@ -393,9 +371,6 @@ bool inited = false;
DS::fileHandle handle[MAX_FILE_HANDLES];
FILE* std_fopen(const char* name, const char* mode) {
-
-
-
if (!inited) {
for (int r = 0; r < MAX_FILE_HANDLES; r++) {
handle[r].used = false;
@@ -403,9 +378,6 @@ FILE* std_fopen(const char* name, const char* mode) {
inited = true;
currentDir[0] = '\0';
}
-
-
-
char* realName = (char *) name;
@@ -413,7 +385,7 @@ FILE* std_fopen(const char* name, const char* mode) {
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;
}
@@ -421,7 +393,6 @@ FILE* std_fopen(const char* name, const char* mode) {
// consolePrintf("Open file:");
// consolePrintf("'%s', [%s]", realName, mode);
-
if (DS::isGBAMPAvailable()) {
FAT_chdir("/");
@@ -443,10 +414,9 @@ FILE* std_fopen(const char* name, const char* mode) {
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++;
@@ -459,7 +429,6 @@ FILE* std_fopen(const char* name, const char* mode) {
handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, false);
}
-
if (handle[r].sramFile) {
handle[r].used = true;
handle[r].pos = 0;
@@ -513,6 +482,7 @@ FILE* std_fopen(const char* name, const char* mode) {
return NULL;
}
}
+
void std_fclose(FILE* handle) {
if (DS::isGBAMPAvailable()) {
@@ -528,14 +498,9 @@ void std_fclose(FILE* handle) {
}
size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
-
// consolePrintf("fread %d,%d %d ", size, numItems, ptr);
-
-
if (DS::isGBAMPAvailable()) {
-
-
int bytes = FAT_fread((void *) ptr, size, numItems, (FAT_FILE *) handle);
if (!std_feof(handle)) {
return numItems;
@@ -560,27 +525,24 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
}
- return item;*/
-
-
+ return item;
+*/
int items = 0;
//for (int r = 0; r < numItems; r++) {
if (!std_feof(handle)) {
-
-
-
/* for (int t = 0; t < size; t++) {
if (feof(handle)) eof = true;
*(((char *) (ptr)) + r * size + t) = getc(handle);
}*/
int left = size * numItems;
int bytesRead = -1;
+
while ((left > 0) && (!FAT_feof((FAT_FILE *) handle))) {
int amount = left > 8192? 8192: left;
// do {
bytesRead = FAT_fread((void *) ptr, 1, amount, (FAT_FILE *) handle);
- /* if (bytesRead == 0) {
+/* if (bytesRead == 0) {
consolePrintf("Pos:%d items:%d num:%d amount:%d read:%d\n", ftell(handle), items, numItems, amount, bytesRead);
left++;
@@ -592,27 +554,24 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
fread(ptr, 1024, 1, handle);
swiWaitForVBlank();
//while (true);
- }*/
- //} while (bytesRead == 0);
+ }
+
+ } while (bytesRead == 0);
+*/
left -= 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) {
@@ -630,7 +589,6 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
return bytes / size;
}
-
if (handle->pos + size * numItems > handle->size) {
numItems = (handle->size - handle->pos) / size;
if (numItems < 0) numItems = 0;
@@ -639,10 +597,8 @@ size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
// consolePrintf("read %d ", size * numItems);
memcpy((void *) ptr, handle->data + handle->pos, size * numItems);
-
handle->pos += size * numItems;
-
return numItems;
}
@@ -657,7 +613,6 @@ size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle) {
//consolePrintf("fwrite size=%d\n", size * numItems);
if (DS::isGBAMPAvailable()) {
-
FAT_fwrite(((char *) (ptr)), size, numItems, (FAT_FILE *) handle);
return numItems;
@@ -675,7 +630,6 @@ size_t std_fwrite(const void* ptr, size_t size, size_t numItems, FILE* handle) {
return numItems;
}
-
if (handle->sramFile) {
handle->sramFile->write(ptr, size);
return size;
@@ -704,6 +658,7 @@ bool std_feof(FILE* handle) {
}
void std_fflush(FILE* handle) {
+ //FIXME: not implemented?
// consolePrintf("fflush ");
}
@@ -711,7 +666,6 @@ 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);
@@ -723,7 +677,6 @@ char* std_fgets(char* str, int size, FILE* file) {
return str;
}
-
if (file->sramFile) {
file->pos--;
int p = -1;
@@ -743,7 +696,6 @@ char* std_fgets(char* str, int size, FILE* file) {
}
long int std_ftell(FILE* handle) {
-
if (DS::isGBAMPAvailable()) {
return FAT_ftell((FAT_FILE *) handle);
}
@@ -758,39 +710,30 @@ int std_fseek(FILE* handle, long int offset, int whence) {
return FAT_fseek((FAT_FILE *) handle, offset, whence);
}
-
switch (whence) {
- case SEEK_CUR: {
+ case SEEK_CUR:
handle->pos += offset;
break;
- }
-
- case SEEK_SET: {
+ case SEEK_SET:
handle->pos = offset;
break;
- }
-
- case SEEK_END: {
+ case SEEK_END:
handle->pos = handle->size + offset;
break;
- }
-
- default: {
+ default:
handle->pos = offset;
break;
- }
-
}
return 0;
}
void std_clearerr(FILE* handle) {
+ //FIXME: not implemented?
// consolePrintf("clearerr ");
}
int std_getc(FILE* handle) {
-
if (DS::isGBAMPAvailable()) {
char c;
FAT_fread(&c, 1, 1, (FAT_FILE *) handle);
@@ -852,24 +795,3 @@ int std_ferror(FILE* handle) {
}
} // namespace DS
-
-// These functions are added to AbstractFileSystemNode and are therefore outside
-// the DS namespace.
-
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
-// consolePrintf("New node");
-
- if (DS::isGBAMPAvailable()) {
- return new DS::GBAMPFileSystemNode();
- } else {
- return new DS::DSFileSystemNode();
- }
-}
-
-AbstractFilesystemNode* AbstractFilesystemNode::getNodeForPath(const String& path) {
- if (DS::isGBAMPAvailable()) {
- return new DS::GBAMPFileSystemNode(path);
- } else {
- return new DS::DSFileSystemNode(path);
- }
-}
diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h
index ef651b7ea7..ead0acc05e 100644
--- a/backends/fs/ds/ds-fs.h
+++ b/backends/fs/ds/ds-fs.h
@@ -23,8 +23,6 @@
#ifndef _DS_FS_H
#define _DS_FS_H
-
-
//#include <NDS/ARM9/console.h>
#include "fs.h"
#include "zipreader.h"
@@ -32,81 +30,137 @@
#include "scummconsole.h"
#include "gba_nds_fat.h"
#include "backends/fs/abstract-fs.h"
-//#include "backends/fs/fs.h"
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 {
protected:
- static ZipFile* _zipFile;
-
typedef class Common::String String;
+ static ZipFile* _zipFile;
+
String _displayName;
+ String _path;
bool _isDirectory;
bool _isValid;
- String _path;
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);
- DSFileSystemNode(const DSFileSystemNode *node);
+
+ /**
+ * 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);
- virtual String displayName() const { return _displayName; }
- virtual String name() const { return _displayName; }
- virtual bool isValid() const { return _isValid; }
+ /**
+ * 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; }
+ virtual String getPath() const { return _path; }
virtual bool isDirectory() const { return _isDirectory; }
- virtual String path() const { return _path; }
+ virtual bool isReadable() const { return true; } //FIXME: this is just a stub
+ virtual bool isValid() const { return _isValid; }
+ virtual bool isWritable() const { return true; } //FIXME: this is just a stub
- virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
- virtual AbstractFilesystemNode *parent() const;
+ /**
+ * Returns a copy of this node.
+ */
virtual AbstractFilesystemNode *clone() const { return new DSFileSystemNode(this); }
- virtual AbstractFilesystemNode *child(const Common::String& name) const;
+ virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
+ virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly, bool hidden) const;
+ virtual AbstractFilesystemNode *getParent() const;
+
+ /**
+ * Returns the zip file this node points to.
+ * TODO: check this documentation.
+ */
static ZipFile* getZip() { return _zipFile; }
};
-
-/**
+ /**
+ * 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 {
protected:
typedef class Common::String String;
String _displayName;
+ String _path;
bool _isDirectory;
bool _isValid;
- String _path;
-
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 String displayName() const { return _displayName; }
- virtual String name() const { return _displayName; }
-
- virtual bool isValid() const { return _isValid; }
+ virtual bool exists() const { return true; } //FIXME: this is just a stub
+ 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 String path() const { return _path; }
- virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
- virtual AbstractFilesystemNode *parent() const;
- virtual AbstractFilesystemNode *clone() const { return new GBAMPFileSystemNode(this); }
- virtual AbstractFilesystemNode *child(const Common::String& name) const;
+ virtual bool isReadable() const { return true; } //FIXME: this is just a stub
+ virtual bool isValid() const { return _isValid; }
+ virtual bool isWritable() const { return true; } //FIXME: this is just a stub
+ /**
+ * Returns a copy of this node.
+ */
+ virtual AbstractFilesystemNode *clone() const { return new GBAMPFileSystemNode(this); }
+ virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
+ virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly, bool hidden) const;
+ virtual AbstractFilesystemNode *getParent() const;
};
-
-
-
struct fileHandle {
int pos;
bool used;
@@ -116,7 +170,6 @@ struct fileHandle {
DSSaveFile* sramFile;
};
-
#undef stderr
#undef stdout
#undef stdin
@@ -140,6 +193,6 @@ void std_clearerr(FILE* handle);
void std_cwd(char* dir);
void std_fflush(FILE* handle);
-}
+} //namespace DS
-#endif
+#endif //_DS_FS_H