aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/psp
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/psp
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/psp')
-rw-r--r--backends/fs/psp/psp-fs-factory.cpp40
-rw-r--r--backends/fs/psp/psp-fs-factory.h51
-rw-r--r--backends/fs/psp/psp_fs.cpp110
3 files changed, 151 insertions, 50 deletions
diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp
new file mode 100644
index 0000000000..e1d2b8fb49
--- /dev/null
+++ b/backends/fs/psp/psp-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/psp/psp-fs-factory.h"
+#include "backends/fs/psp/psp_fs.cpp"
+
+DECLARE_SINGLETON(PSPFilesystemFactory);
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const {
+ return new PSPFilesystemNode();
+}
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const {
+ return new PSPFilesystemNode();
+}
+
+AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const String &path) const {
+ return new PSPFilesystemNode(path, true);
+}
diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h
new file mode 100644
index 0000000000..83a59dcc6a
--- /dev/null
+++ b/backends/fs/psp/psp-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 PSP_FILESYSTEM_FACTORY_H
+#define PSP_FILESYSTEM_FACTORY_H
+
+#include "common/singleton.h"
+#include "backends/fs/abstract-fs-factory.h"
+
+/**
+ * Creates PSPFilesystemNode objects.
+ *
+ * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
+ */
+class PSPFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PSPFilesystemFactory> {
+public:
+ typedef Common::String String;
+
+ virtual AbstractFilesystemNode *makeRootFileNode() const;
+ virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
+ virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
+
+protected:
+ PSPFilesystemFactory() {};
+
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+};
+
+#endif /*PSP_FILESYSTEM_FACTORY_H*/
diff --git a/backends/fs/psp/psp_fs.cpp b/backends/fs/psp/psp_fs.cpp
index 3f25a63f86..019b13e9e6 100644
--- a/backends/fs/psp/psp_fs.cpp
+++ b/backends/fs/psp/psp_fs.cpp
@@ -23,8 +23,8 @@
*/
#ifdef __PSP__
-#include "engines/engine.h"
+#include "engines/engine.h"
#include "backends/fs/abstract-fs.h"
#include <sys/stat.h>
@@ -32,39 +32,65 @@
#define ROOT_PATH "ms0:/"
-
-/*
+/**
* Implementation of the ScummVM file system API based on PSPSDK API.
+ *
+ * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
*/
-
class PSPFilesystemNode : public AbstractFilesystemNode {
protected:
String _displayName;
+ String _path;
bool _isDirectory;
bool _isValid;
- String _path;
public:
+ /**
+ * Creates a PSPFilesystemNode with the root node as path.
+ */
PSPFilesystemNode();
+
+ /**
+ * Creates a PSPFilesystemNode for a given path.
+ *
+ * @param path String with the path the new node should point to.
+ * @param verify true if the isValid and isDirectory flags should be verified during the construction.
+ */
PSPFilesystemNode(const Common::String &p, bool verify);
- 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 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) const;
- virtual AbstractFilesystemNode *parent() const;
- 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();
-}
+/**
+ * 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.
+ */
+static const char *lastPathComponent(const Common::String &str) {
+ const char *start = str.c_str();
+ const char *cur = start + str.size() - 2;
-AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
- return new PSPFilesystemNode();
+ while (cur >= start && *cur != '/') {
+ --cur;
+ }
+
+ return cur + 1;
}
PSPFilesystemNode::PSPFilesystemNode() {
@@ -89,14 +115,24 @@ PSPFilesystemNode::PSPFilesystemNode(const Common::String &p, bool verify) {
}
}
-AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
- return new PSPFilesystemNode(path, true);
-}
+AbstractFilesystemNode *PSPFilesystemNode::getChild(const String &n) const {
+ // FIXME: Pretty lame implementation! We do no error checking to speak
+ // of, do not check if this is a special node, etc.
+ assert(_isDirectory);
+
+ String newPath(_path);
+ if (_path.lastChar() != '/')
+ newPath += '/';
+ newPath += n;
+ return new PSPFilesystemNode(newPath, true);
+}
-bool PSPFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
+bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
assert(_isDirectory);
+ //TODO: honor the hidden flag
+
int dfd = sceIoDopen(_path.c_str());
if (dfd > 0) {
SceIoDirent dir;
@@ -133,18 +169,7 @@ bool PSPFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
}
}
-static const char *lastPathComponent(const Common::String &str) {
- const char *start = str.c_str();
- const char *cur = start + str.size() - 2;
-
- while (cur >= start && *cur != '/') {
- --cur;
- }
-
- return cur + 1;
-}
-
-AbstractFilesystemNode *PSPFilesystemNode::parent() const {
+AbstractFilesystemNode *PSPFilesystemNode::getParent() const {
assert(_isValid);
if (_path == ROOT_PATH)
@@ -153,22 +178,7 @@ AbstractFilesystemNode *PSPFilesystemNode::parent() const {
const char *start = _path.c_str();
const char *end = lastPathComponent(_path);
- PSPFilesystemNode *p = new PSPFilesystemNode(String(start, end - start), false);
-
- return p;
-}
-
-AbstractFilesystemNode *PSPFilesystemNode::child(const String &n) const {
- // FIXME: Pretty lame implementation! We do no error checking to speak
- // of, do not check if this is a special node, etc.
- assert(_isDirectory);
- String newPath(_path);
- if (_path.lastChar() != '/')
- newPath += '/';
- newPath += n;
- PSPFilesystemNode *p = new PSPFilesystemNode(newPath, true);
-
- return p;
+ return new PSPFilesystemNode(String(start, end - start), false);
}
-#endif // PSP
+#endif //#ifdef __PSP__