aboutsummaryrefslogtreecommitdiff
path: root/common/fs.cpp
diff options
context:
space:
mode:
authorMax Horn2008-09-03 10:40:46 +0000
committerMax Horn2008-09-03 10:40:46 +0000
commitc350ffabf3d589722b1bee95f63a783fbf39cc1b (patch)
tree128a1ad81917fee118ebd0174f52717cbd6d3391 /common/fs.cpp
parent8246582f5e3007a014cc22fc2840bd951e0c9b7f (diff)
downloadscummvm-rg350-c350ffabf3d589722b1bee95f63a783fbf39cc1b.tar.gz
scummvm-rg350-c350ffabf3d589722b1bee95f63a783fbf39cc1b.tar.bz2
scummvm-rg350-c350ffabf3d589722b1bee95f63a783fbf39cc1b.zip
Added new AbstractFilesystemNode::openForReading & ::openForWriting method, based on StdioStream; changed FilesystemNode to use them
svn-id: r34301
Diffstat (limited to 'common/fs.cpp')
-rw-r--r--common/fs.cpp40
1 files changed, 15 insertions, 25 deletions
diff --git a/common/fs.cpp b/common/fs.cpp
index 429d388ad1..fb34509d6a 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -23,7 +23,6 @@
*/
#include "common/util.h"
-#include "common/file.h"
#include "common/system.h"
#include "backends/fs/abstract-fs.h"
#include "backends/fs/fs-factory.h"
@@ -177,37 +176,28 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h
Common::SeekableReadStream *FilesystemNode::openForReading() {
if (_realNode == 0)
return 0;
-#if 0
- return _realNode->openForReading();
-#else
- // FIXME: Until we support openForReading in AbstractFilesystemNode,
- // we just use Common::File.
- Common::File *confFile = new Common::File();
- assert(confFile);
- if (!confFile->open(*this)) {
- delete confFile;
- confFile = 0;
+
+ if (!_realNode->exists()) {
+ warning("File::open: Trying to open a FilesystemNode which does not exist");
+ return false;
+ } else if (_realNode->isDirectory()) {
+ warning("File::open: Trying to open a FilesystemNode which is a directory");
+ return false;
}
- return confFile;
-#endif
+
+ return _realNode->openForReading();
}
Common::WriteStream *FilesystemNode::openForWriting() {
if (_realNode == 0)
return 0;
-#if 0
- return _realNode->openForWriting();
-#else
- // FIXME: Until we support openForWriting in AbstractFilesystemNode,
- // we just use Common::DumpFile.
- Common::DumpFile *confFile = new Common::DumpFile();
- assert(confFile);
- if (!confFile->open(*this)) {
- delete confFile;
- confFile = 0;
+
+ if (_realNode->isDirectory()) {
+ warning("File::open: Trying to open a FilesystemNode which is a directory");
+ return 0;
}
- return confFile;
-#endif
+
+ return _realNode->openForWriting();
}
//} // End of namespace Common