aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/ps2
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/ps2
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/ps2')
-rw-r--r--backends/fs/ps2/ps2-fs-factory.cpp40
-rw-r--r--backends/fs/ps2/ps2-fs-factory.h51
-rw-r--r--backends/fs/ps2/ps2-fs.cpp130
3 files changed, 162 insertions, 59 deletions
diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp
new file mode 100644
index 0000000000..570fbd008c
--- /dev/null
+++ b/backends/fs/ps2/ps2-fs-factory.cpp
@@ -0,0 +1,40 @@
+/* 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/ps2/ps2-fs-factory.h"
+#include "backends/fs/ps2/ps2-fs.cpp"
+
+DECLARE_SINGLETON(Ps2FilesystemFactory);
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const {
+ return new Ps2FilesystemNode();
+}
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const {
+ return new Ps2FilesystemNode();
+}
+
+AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const {
+ return new Ps2FilesystemNode(path);
+}
diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h
new file mode 100644
index 0000000000..9798b2b497
--- /dev/null
+++ b/backends/fs/ps2/ps2-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 PS2_FILESYSTEM_FACTORY_H
+#define PS2_FILESYSTEM_FACTORY_H
+
+#include "common/singleton.h"
+#include "backends/fs/abstract-fs-factory.h"
+
+/**
+ * Creates PS2FilesystemNode objects.
+ *
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class Ps2FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<Ps2FilesystemFactory> {
+public:
+ typedef Common::String String;
+
+ virtual AbstractFilesystemNode *makeRootFileNode() const;
+ virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+ virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+
+protected:
+ Ps2FilesystemFactory() {};
+
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+};
+
+#endif /*PS2_FILESYSTEM_FACTORY_H*/
diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp
index afe1842e43..727e1a894f 100644
--- a/backends/fs/ps2/ps2-fs.cpp
+++ b/backends/fs/ps2/ps2-fs.cpp
@@ -32,44 +32,52 @@
extern AsyncFio fio;
extern OSystem_PS2 *g_systemPs2;
+/**
+ * Implementation of the ScummVM file system API based on the Ps2SDK.
+ *
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
+ */
class Ps2FilesystemNode : public AbstractFilesystemNode {
protected:
String _displayName;
+ String _path;
bool _isDirectory;
bool _isRoot;
- String _path;
public:
- Ps2FilesystemNode(void);
- Ps2FilesystemNode(const Ps2FilesystemNode *node);
+ /**
+ * Creates a PS2FilesystemNode with the root node as path.
+ */
+ Ps2FilesystemNode();
+
+ /**
+ * Creates a PS2FilesystemNode for a given path.
+ *
+ * @param path String with the path the new node should point to.
+ */
Ps2FilesystemNode(const String &path);
+
+ /**
+ * Copy constructor.
+ */
+ Ps2FilesystemNode(const Ps2FilesystemNode *node);
- virtual String displayName() const { return _displayName; }
- virtual String name() const { return _displayName; }
- virtual bool isValid() const { return !_isRoot; }
+ 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 !_isRoot; }
+ virtual bool isWritable() const { return true; } //FIXME: this is just a stub
- //virtual FSList listDir(ListMode) const;
- virtual bool listDir(AbstractFSList &list, ListMode mode) const;
- virtual AbstractFilesystemNode *parent() const;
virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
- virtual AbstractFilesystemNode *child(const String &n) const;
+ virtual AbstractFilesystemNode *getChild(const String &n) const;
+ virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
+ virtual AbstractFilesystemNode *getParent() const;
};
-AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
- return AbstractFilesystemNode::getRoot();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot(void) {
- return new Ps2FilesystemNode();
-}
-
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
- return new Ps2FilesystemNode(path);
-}
-
-Ps2FilesystemNode::Ps2FilesystemNode(void) {
+Ps2FilesystemNode::Ps2FilesystemNode() {
_isDirectory = true;
_isRoot = true;
_displayName = "PlayStation 2";
@@ -108,7 +116,43 @@ Ps2FilesystemNode::Ps2FilesystemNode(const Ps2FilesystemNode *node) {
_isRoot = node->_isRoot;
}
-bool Ps2FilesystemNode::listDir(AbstractFSList &list, ListMode mode) const {
+AbstractFilesystemNode *Ps2FilesystemNode::getChild(const String &n) const {
+ if (!_isDirectory)
+ return NULL;
+
+ char listDir[256];
+ sprintf(listDir, "%s/", _path.c_str());
+ int fd = fio.dopen(listDir);
+
+ if (fd >= 0) {
+ iox_dirent_t dirent;
+
+ while (fio.dread(fd, &dirent) > 0) {
+ if (strcmp(n.c_str(), dirent.name) == 0) {
+ Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
+
+ dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
+ dirEntry->_isRoot = false;
+
+ dirEntry->_path = _path;
+ dirEntry->_path += "/";
+ dirEntry->_path += dirent.name;
+
+ dirEntry->_displayName = dirent.name;
+
+ fio.dclose(fd);
+ return dirEntry;
+ }
+ }
+ fio.dclose(fd);
+ }
+
+ return NULL;
+}
+
+bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
+ //TODO: honor the hidden flag
+
if (!_isDirectory)
return false;
@@ -135,6 +179,7 @@ bool Ps2FilesystemNode::listDir(AbstractFSList &list, ListMode mode) const {
} else {
char listDir[256];
int fd;
+
if (_path.lastChar() == '/')
fd = fio.dopen(_path.c_str());
else {
@@ -173,7 +218,7 @@ bool Ps2FilesystemNode::listDir(AbstractFSList &list, ListMode mode) const {
}
}
-AbstractFilesystemNode *Ps2FilesystemNode::parent() const {
+AbstractFilesystemNode *Ps2FilesystemNode::getParent() const {
if (_isRoot)
return new Ps2FilesystemNode(this);
@@ -191,36 +236,3 @@ AbstractFilesystemNode *Ps2FilesystemNode::parent() const {
else
return new Ps2FilesystemNode();
}
-
-AbstractFilesystemNode *Ps2FilesystemNode::child(const String &n) const {
- if (!_isDirectory)
- return NULL;
-
- char listDir[256];
- sprintf(listDir, "%s/", _path.c_str());
- int fd = fio.dopen(listDir);
-
- if (fd >= 0) {
- iox_dirent_t dirent;
-
- while (fio.dread(fd, &dirent) > 0) {
- if (strcmp(n.c_str(), dirent.name) == 0) {
- Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
-
- dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
- dirEntry->_isRoot = false;
-
- dirEntry->_path = _path;
- dirEntry->_path += "/";
- dirEntry->_path += dirent.name;
-
- dirEntry->_displayName = dirent.name;
-
- fio.dclose(fd);
- return dirEntry;
- }
- }
- fio.dclose(fd);
- }
- return NULL;
-}