aboutsummaryrefslogtreecommitdiff
path: root/backends/fs
diff options
context:
space:
mode:
Diffstat (limited to 'backends/fs')
-rw-r--r--backends/fs/abstract-fs.cpp19
-rw-r--r--backends/fs/abstract-fs.h21
2 files changed, 37 insertions, 3 deletions
diff --git a/backends/fs/abstract-fs.cpp b/backends/fs/abstract-fs.cpp
index f6dc8f1891..db2baee6ca 100644
--- a/backends/fs/abstract-fs.cpp
+++ b/backends/fs/abstract-fs.cpp
@@ -23,6 +23,7 @@
*/
#include "backends/fs/abstract-fs.h"
+#include "common/file.h"
const char *AbstractFilesystemNode::lastPathComponent(const Common::String &str, const char sep) {
if(str.empty())
@@ -37,3 +38,21 @@ const char *AbstractFilesystemNode::lastPathComponent(const Common::String &str,
return cur + 1;
}
+
+Common::SeekableReadStream *AbstractFilesystemNode::openForReading() {
+ // FIXME: Until openForReading is supported by all AbstractFilesystemNode
+ // implementations, we provide this "generic" one, using Common::File.
+ FILE *handle = fopen(getPath().c_str(), "rb");
+ if (handle)
+ return new Common::StdioStream(handle);
+ return 0;
+}
+
+Common::WriteStream *AbstractFilesystemNode::openForWriting() {
+ // FIXME: Until openForWriting is supported by all AbstractFilesystemNode
+ // implementations, we provide this "generic" one.
+ FILE *handle = fopen(getPath().c_str(), "wb");
+ if (handle)
+ return new Common::StdioStream(handle);
+ return 0;
+}
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h
index d81e7f36b0..73fae24373 100644
--- a/backends/fs/abstract-fs.h
+++ b/backends/fs/abstract-fs.h
@@ -162,9 +162,24 @@ public:
*/
virtual bool isWritable() const = 0;
- /* TODO:
- bool isFile();
- */
+
+ /**
+ * Creates a SeekableReadStream instance corresponding to the file
+ * referred by this node. This assumes that the node actually refers
+ * to a readable file. If this is not the case, 0 is returned.
+ *
+ * @return pointer to the stream object, 0 in case of a failure
+ */
+ virtual Common::SeekableReadStream *openForReading();
+
+ /**
+ * Creates a WriteStream instance corresponding to the file
+ * referred by this node. This assumes that the node actually refers
+ * to a readable file. If this is not the case, 0 is returned.
+ *
+ * @return pointer to the stream object, 0 in case of a failure
+ */
+ virtual Common::WriteStream *openForWriting();
};