aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2008-09-03 17:07:13 +0000
committerMax Horn2008-09-03 17:07:13 +0000
commite1918341afd6f7a8f1fa3db8838e582f8e8a511c (patch)
tree7d7e6690bb731dff462b6500828ad172c89a2393 /common
parent18fb6348dd62df1c6e25dea402f4997dc908d281 (diff)
downloadscummvm-rg350-e1918341afd6f7a8f1fa3db8838e582f8e8a511c.tar.gz
scummvm-rg350-e1918341afd6f7a8f1fa3db8838e582f8e8a511c.tar.bz2
scummvm-rg350-e1918341afd6f7a8f1fa3db8838e582f8e8a511c.zip
Changed Archive::openFile to return a SeekableReadStream* instead of a FilePtr
svn-id: r34312
Diffstat (limited to 'common')
-rw-r--r--common/archive.cpp16
-rw-r--r--common/archive.h10
2 files changed, 15 insertions, 11 deletions
diff --git a/common/archive.cpp b/common/archive.cpp
index b963cf4ceb..575fa3857d 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -70,19 +70,19 @@ bool FSDirectory::hasFile(const String &name) {
return node.exists();
}
-FilePtr FSDirectory::openFile(const String &name) {
+SeekableReadStream *FSDirectory::openFile(const String &name) {
if (name.empty() || !_node.isDirectory()) {
- return FilePtr();
+ return 0;
}
FilesystemNode node = lookupCache(_fileCache, name);
if (!node.exists()) {
warning("FSDirectory::openFile: Trying to open a FilesystemNode which does not exist");
- return FilePtr();
+ return 0;
} else if (node.isDirectory()) {
warning("FSDirectory::openFile: Trying to open a FilesystemNode which is a directory");
- return FilePtr();
+ return 0;
}
SeekableReadStream *stream = node.openForReading();
@@ -90,7 +90,7 @@ FilePtr FSDirectory::openFile(const String &name) {
warning("FSDirectory::openFile: Can't create stream for file '%s'", name.c_str());
}
- return FilePtr(stream);
+ return stream;
}
SharedPtr<FSDirectory> FSDirectory::getSubDirectory(const String &name) {
@@ -269,9 +269,9 @@ int SearchSet::matchPattern(StringList &list, const String &pattern) {
return matches;
}
-FilePtr SearchSet::openFile(const String &name) {
+SeekableReadStream *SearchSet::openFile(const String &name) {
if (name.empty()) {
- return FilePtr();
+ return 0;
}
ArchiveList::iterator it = _list.begin();
@@ -281,7 +281,7 @@ FilePtr SearchSet::openFile(const String &name) {
}
}
- return FilePtr();
+ return 0;
}
diff --git a/common/archive.h b/common/archive.h
index 636fb6383f..4daeb51d82 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -35,6 +35,10 @@
namespace Common {
+/**
+ * FilePtr is a convenient way to keep track of a SeekableReadStream without
+ * having to worry about releasing its memory.
+ */
typedef SharedPtr<SeekableReadStream> FilePtr;
/**
@@ -75,7 +79,7 @@ public:
* Create a stream bound to a file in the archive.
* @return The newly created input stream.
*/
- virtual FilePtr openFile(const String &name) = 0;
+ virtual SeekableReadStream *openFile(const String &name) = 0;
};
@@ -136,7 +140,7 @@ public:
virtual bool hasFile(const String &name);
virtual int matchPattern(StringList &list, const String &pattern);
- virtual FilePtr openFile(const String &name);
+ virtual SeekableReadStream *openFile(const String &name);
};
@@ -193,7 +197,7 @@ public:
* Implements openFile from Archive base class. The current policy is
* opening the first file encountered that matches the name.
*/
- virtual FilePtr openFile(const String &name);
+ virtual SeekableReadStream *openFile(const String &name);
};
} // namespace Common