Renamed Archive::openFile to createReadStreamForMember

svn-id: r36021
This commit is contained in:
Max Horn 2009-01-23 04:45:44 +00:00
parent 9861afd8fd
commit 14c5bbbccf
21 changed files with 47 additions and 47 deletions

View file

@ -252,7 +252,7 @@ bool VirtualKeyboardParser::parserCallback_layout(ParserNode *node) {
_mode->bitmapName = node->values["bitmap"]; _mode->bitmapName = node->values["bitmap"];
SeekableReadStream *file = _keyboard->_fileArchive->openFile(_mode->bitmapName); SeekableReadStream *file = _keyboard->_fileArchive->createReadStreamForMember(_mode->bitmapName);
if (!file) if (!file)
return parserError("Bitmap '%s' not found", _mode->bitmapName.c_str()); return parserError("Bitmap '%s' not found", _mode->bitmapName.c_str());

View file

@ -103,7 +103,7 @@ bool VirtualKeyboard::loadKeyboardPack(String packName) {
#ifdef USE_ZLIB #ifdef USE_ZLIB
_fileArchive = new ZipArchive(vkDir.getChild(packName + ".zip")); _fileArchive = new ZipArchive(vkDir.getChild(packName + ".zip"));
if (_fileArchive->hasFile(packName + ".xml")) { if (_fileArchive->hasFile(packName + ".xml")) {
if (!_parser->loadStream(_fileArchive->openFile(packName + ".xml"))) if (!_parser->loadStream(_fileArchive->createReadStreamForMember(packName + ".xml")))
return false; return false;
} else { } else {
warning("Could not find %s.xml file in %s.zip keyboard pack", packName.c_str(), packName.c_str()); warning("Could not find %s.xml file in %s.zip keyboard pack", packName.c_str(), packName.c_str());

View file

@ -39,7 +39,7 @@ String GenericArchiveMember::getName() const {
} }
SeekableReadStream *GenericArchiveMember::createReadStream() const { SeekableReadStream *GenericArchiveMember::createReadStream() const {
return _parent->openFile(_name); return _parent->createReadStreamForMember(_name);
} }
@ -136,23 +136,23 @@ ArchiveMemberPtr FSDirectory::getMember(const String &name) {
return ArchiveMemberPtr(new FSNode(node)); return ArchiveMemberPtr(new FSNode(node));
} }
SeekableReadStream *FSDirectory::openFile(const String &name) const { SeekableReadStream *FSDirectory::createReadStreamForMember(const String &name) const {
if (name.empty() || !_node.isDirectory()) if (name.empty() || !_node.isDirectory())
return 0; return 0;
FSNode node = lookupCache(_fileCache, name); FSNode node = lookupCache(_fileCache, name);
if (!node.exists()) { if (!node.exists()) {
warning("FSDirectory::openFile: FSNode does not exist"); warning("FSDirectory::createReadStreamForMember: FSNode does not exist");
return 0; return 0;
} else if (node.isDirectory()) { } else if (node.isDirectory()) {
warning("FSDirectory::openFile: FSNode is a directory"); warning("FSDirectory::createReadStreamForMember: FSNode is a directory");
return 0; return 0;
} }
SeekableReadStream *stream = node.createReadStream(); SeekableReadStream *stream = node.createReadStream();
if (!stream) if (!stream)
warning("FSDirectory::openFile: Can't create stream for file '%s'", name.c_str()); warning("FSDirectory::createReadStreamForMember: Can't create stream for file '%s'", name.c_str());
return stream; return stream;
} }
@ -434,14 +434,14 @@ ArchiveMemberPtr SearchSet::getMember(const String &name) {
return ArchiveMemberPtr(); return ArchiveMemberPtr();
} }
SeekableReadStream *SearchSet::openFile(const String &name) const { SeekableReadStream *SearchSet::createReadStreamForMember(const String &name) const {
if (name.empty()) if (name.empty())
return 0; return 0;
ArchiveNodeList::iterator it = _list.begin(); ArchiveNodeList::iterator it = _list.begin();
for ( ; it != _list.end(); ++it) { for ( ; it != _list.end(); ++it) {
if (it->_arc->hasFile(name)) if (it->_arc->hasFile(name))
return it->_arc->openFile(name); return it->_arc->createReadStreamForMember(name);
} }
return 0; return 0;

View file

@ -95,7 +95,7 @@ public:
/** /**
* Add all the names present in the Archive which match pattern to * Add all the names present in the Archive which match pattern to
* list. Returned names can be used as parameters to openFile. * list. Returned names can be used as parameters to createReadStreamForMember.
* Must not remove elements from the list. * Must not remove elements from the list.
* *
* @return the number of names added to list * @return the number of names added to list
@ -104,7 +104,7 @@ public:
/** /**
* Add all the names present in the Archive to list. Returned * Add all the names present in the Archive to list. Returned
* names can be used as parameters to openFile. * names can be used as parameters to createReadStreamForMember.
* Must not remove elements from the list. * Must not remove elements from the list.
* *
* @return the number of names added to list * @return the number of names added to list
@ -120,7 +120,7 @@ public:
* Create a stream bound to a file in the archive. * Create a stream bound to a file in the archive.
* @return the newly created input stream * @return the newly created input stream
*/ */
virtual SeekableReadStream *openFile(const String &name) const = 0; virtual SeekableReadStream *createReadStreamForMember(const String &name) const = 0;
}; };
@ -194,10 +194,10 @@ public:
virtual ArchiveMemberPtr getMember(const String &name); virtual ArchiveMemberPtr getMember(const String &name);
/** /**
* Implements openFile from Archive base class. The current policy is * Implements createReadStreamForMember from Archive base class. The current policy is
* opening the first file encountered that matches the name. * opening the first file encountered that matches the name.
*/ */
virtual SeekableReadStream *openFile(const String &name) const; virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
}; };

View file

@ -62,12 +62,12 @@ bool File::open(const String &filename, Archive &archive) {
SeekableReadStream *stream = 0; SeekableReadStream *stream = 0;
if (archive.hasFile(filename)) { if (archive.hasFile(filename)) {
debug(3, "Opening hashed: %s", filename.c_str()); debug(3, "Opening hashed: %s", filename.c_str());
stream = archive.openFile(filename); stream = archive.createReadStreamForMember(filename);
} else if (archive.hasFile(filename + ".")) { } else if (archive.hasFile(filename + ".")) {
// WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails"
// sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot)
debug(3, "Opening hashed: %s.", filename.c_str()); debug(3, "Opening hashed: %s.", filename.c_str());
stream = archive.openFile(filename + "."); stream = archive.createReadStreamForMember(filename + ".");
} }
return open(stream, filename); return open(stream, filename);

View file

@ -243,7 +243,7 @@ public:
* Again, only SLASHES are used as separators independently from the * Again, only SLASHES are used as separators independently from the
* underlying file system. * underlying file system.
* *
* Relative paths can be specified when calling matching functions like openFile(), * Relative paths can be specified when calling matching functions like createReadStreamForMember(),
* hasFile(), listMatchingMembers() and listMembers(). Please see the function * hasFile(), listMatchingMembers() and listMembers(). Please see the function
* specific comments for more information. * specific comments for more information.
* *
@ -333,7 +333,7 @@ public:
* Open the specified file. A full match of relative path and filename is needed * Open the specified file. A full match of relative path and filename is needed
* for success. * for success.
*/ */
virtual SeekableReadStream *openFile(const String &name) const; virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
}; };

View file

@ -350,7 +350,7 @@ bool ArjFile::open(const Common::String &filename) {
error("Attempt to open another instance of archive"); error("Attempt to open another instance of archive");
if (_fallBack) { if (_fallBack) {
_uncompressed = SearchMan.openFile(filename); _uncompressed = SearchMan.createReadStreamForMember(filename);
if (_uncompressed) if (_uncompressed)
return true; return true;
} }

View file

@ -1376,7 +1376,7 @@ public:
*/ */
ZipArchive::ZipArchive(const Common::String &name) { ZipArchive::ZipArchive(const Common::String &name) {
SeekableReadStream *stream = SearchMan.openFile(name); SeekableReadStream *stream = SearchMan.createReadStreamForMember(name);
_zipFile = unzOpen(stream); _zipFile = unzOpen(stream);
} }
@ -1428,7 +1428,7 @@ ArchiveMemberPtr ZipArchive::getMember(const String &name) {
return ArchiveMemberPtr(new GenericArchiveMember(name, this)); return ArchiveMemberPtr(new GenericArchiveMember(name, this));
} }
Common::SeekableReadStream *ZipArchive::openFile(const Common::String &name) const { Common::SeekableReadStream *ZipArchive::createReadStreamForMember(const Common::String &name) const {
if (!_zipFile) if (!_zipFile)
return 0; return 0;

View file

@ -62,7 +62,7 @@ public:
virtual bool hasFile(const String &name); virtual bool hasFile(const String &name);
virtual int listMembers(ArchiveMemberList &list); virtual int listMembers(ArchiveMemberList &list);
virtual ArchiveMemberPtr getMember(const String &name); virtual ArchiveMemberPtr getMember(const String &name);
virtual SeekableReadStream *openFile(const String &name) const; virtual SeekableReadStream *createReadStreamForMember(const String &name) const;
}; };
} // End of namespace Common } // End of namespace Common

View file

@ -31,7 +31,7 @@
namespace Common { namespace Common {
bool XMLParser::loadFile(const Common::String &filename) { bool XMLParser::loadFile(const Common::String &filename) {
_stream = SearchMan.openFile(filename); _stream = SearchMan.createReadStreamForMember(filename);
if (!_stream) if (!_stream)
return false; return false;

View file

@ -311,7 +311,7 @@ bool Resource::loadFileToBuf(const char *file, void *buf, uint32 maxSize) {
} }
Common::SeekableReadStream *Resource::getFileStream(const Common::String &file) { Common::SeekableReadStream *Resource::getFileStream(const Common::String &file) {
return _files.openFile(file); return _files.createReadStreamForMember(file);
} }
Common::Archive *Resource::loadArchive(const Common::String &name, Common::SharedPtr<Common::ArchiveMember> member) { Common::Archive *Resource::loadArchive(const Common::String &name, Common::SharedPtr<Common::ArchiveMember> member) {

View file

@ -69,7 +69,7 @@ Common::ArchiveMemberPtr PlainArchive::getMember(const Common::String &name) {
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
} }
Common::SeekableReadStream *PlainArchive::openFile(const Common::String &name) const { Common::SeekableReadStream *PlainArchive::createReadStreamForMember(const Common::String &name) const {
FileMap::const_iterator fDesc = _files.find(name); FileMap::const_iterator fDesc = _files.find(name);
if (fDesc == _files.end()) if (fDesc == _files.end())
return 0; return 0;
@ -124,7 +124,7 @@ Common::ArchiveMemberPtr CachedArchive::getMember(const Common::String &name) {
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
} }
Common::SeekableReadStream *CachedArchive::openFile(const Common::String &name) const { Common::SeekableReadStream *CachedArchive::createReadStreamForMember(const Common::String &name) const {
FileMap::const_iterator fDesc = _files.find(name); FileMap::const_iterator fDesc = _files.find(name);
if (fDesc == _files.end()) if (fDesc == _files.end())
return 0; return 0;

View file

@ -52,7 +52,7 @@ public:
bool hasFile(const Common::String &name); bool hasFile(const Common::String &name);
int listMembers(Common::ArchiveMemberList &list); int listMembers(Common::ArchiveMemberList &list);
Common::ArchiveMemberPtr getMember(const Common::String &name); Common::ArchiveMemberPtr getMember(const Common::String &name);
Common::SeekableReadStream *openFile(const Common::String &name) const; Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
private: private:
struct Entry { struct Entry {
uint32 offset; uint32 offset;
@ -82,7 +82,7 @@ public:
bool hasFile(const Common::String &name); bool hasFile(const Common::String &name);
int listMembers(Common::ArchiveMemberList &list); int listMembers(Common::ArchiveMemberList &list);
Common::ArchiveMemberPtr getMember(const Common::String &name); Common::ArchiveMemberPtr getMember(const Common::String &name);
Common::SeekableReadStream *openFile(const Common::String &name) const; Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
private: private:
struct Entry { struct Entry {
byte *data; byte *data;

View file

@ -101,7 +101,7 @@ Common::SeekableReadStream *Disk_br::openFile_internal(bool errorOnNotFound, con
lookup = name + ext; lookup = name + ext;
} }
Common::SeekableReadStream *stream = _sset.openFile(lookup); Common::SeekableReadStream *stream = _sset.createReadStreamForMember(lookup);
if (stream) { if (stream) {
return stream; return stream;
} }
@ -116,7 +116,7 @@ Common::SeekableReadStream *Disk_br::openFile_internal(bool errorOnNotFound, con
lookup.deleteLastChar(); lookup.deleteLastChar();
} }
lookup += ext; lookup += ext;
stream = _sset.openFile(lookup); stream = _sset.createReadStreamForMember(lookup);
} }
} }

View file

@ -78,7 +78,7 @@ public:
NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features); NSArchive(Common::SeekableReadStream *stream, Common::Platform platform, uint32 features);
~NSArchive(); ~NSArchive();
Common::SeekableReadStream *openFile(const Common::String &name) const; Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
bool hasFile(const Common::String &name); bool hasFile(const Common::String &name);
int listMembers(Common::ArchiveMemberList &list); int listMembers(Common::ArchiveMemberList &list);
Common::ArchiveMemberPtr getMember(const Common::String &name); Common::ArchiveMemberPtr getMember(const Common::String &name);
@ -127,8 +127,8 @@ uint32 NSArchive::lookup(const char *name) const {
return i; return i;
} }
Common::SeekableReadStream *NSArchive::openFile(const Common::String &name) const { Common::SeekableReadStream *NSArchive::createReadStreamForMember(const Common::String &name) const {
debugC(3, kDebugDisk, "NSArchive::openFile(%s)", name.c_str()); debugC(3, kDebugDisk, "NSArchive::createReadStreamForMember(%s)", name.c_str());
if (name.empty()) if (name.empty())
return 0; return 0;
@ -136,7 +136,7 @@ Common::SeekableReadStream *NSArchive::openFile(const Common::String &name) cons
uint32 index = lookup(name.c_str()); uint32 index = lookup(name.c_str());
if (index == _numFiles) return 0; if (index == _numFiles) return 0;
debugC(9, kDebugDisk, "NSArchive::openFile: '%s' found in slot %i", name.c_str(), index); debugC(9, kDebugDisk, "NSArchive::createReadStreamForMember: '%s' found in slot %i", name.c_str(), index);
int offset = _archiveOffsets[index]; int offset = _archiveOffsets[index];
int endOffset = _archiveOffsets[index] + _archiveLenghts[index]; int endOffset = _archiveOffsets[index] + _archiveLenghts[index];
@ -195,7 +195,7 @@ Common::SeekableReadStream *Disk_ns::openFile(const char *filename) {
void Disk_ns::addArchive(const Common::String& name, int priority) { void Disk_ns::addArchive(const Common::String& name, int priority) {
Common::SeekableReadStream *stream = _sset.openFile(name); Common::SeekableReadStream *stream = _sset.createReadStreamForMember(name);
if (!stream) if (!stream)
error("Disk_ns::addArchive() couldn't find archive '%s'", name.c_str()); error("Disk_ns::addArchive() couldn't find archive '%s'", name.c_str());
@ -257,13 +257,13 @@ void DosDisk_ns::init() {
Common::SeekableReadStream *DosDisk_ns::tryOpenFile(const char* name) { Common::SeekableReadStream *DosDisk_ns::tryOpenFile(const char* name) {
debugC(3, kDebugDisk, "DosDisk_ns::tryOpenFile(%s)", name); debugC(3, kDebugDisk, "DosDisk_ns::tryOpenFile(%s)", name);
Common::SeekableReadStream *stream = _sset.openFile(name); Common::SeekableReadStream *stream = _sset.createReadStreamForMember(name);
if (stream) if (stream)
return stream; return stream;
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%s.pp", name); sprintf(path, "%s.pp", name);
return _sset.openFile(path); return _sset.createReadStreamForMember(path);
} }
@ -896,18 +896,18 @@ GfxObj* AmigaDisk_ns::loadStatic(const char* name) {
Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) { Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) {
debugC(3, kDebugDisk, "AmigaDisk_ns::tryOpenFile(%s)", name); debugC(3, kDebugDisk, "AmigaDisk_ns::tryOpenFile(%s)", name);
Common::SeekableReadStream *stream = _sset.openFile(name); Common::SeekableReadStream *stream = _sset.createReadStreamForMember(name);
if (stream) if (stream)
return stream; return stream;
char path[PATH_LEN]; char path[PATH_LEN];
sprintf(path, "%s.pp", name); sprintf(path, "%s.pp", name);
stream = _sset.openFile(path); stream = _sset.createReadStreamForMember(path);
if (stream) if (stream)
return new PowerPackerStream(*stream); return new PowerPackerStream(*stream);
sprintf(path, "%s.dd", name); sprintf(path, "%s.dd", name);
stream = _sset.openFile(path); stream = _sset.createReadStreamForMember(path);
if (stream) if (stream)
return new PowerPackerStream(*stream); return new PowerPackerStream(*stream);

View file

@ -167,7 +167,7 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
} }
/* get file size */ /* get file size */
fi.file = SearchMan.openFile(_fileName); fi.file = SearchMan.createReadStreamForMember(_fileName);
if (!fi.file) { if (!fi.file) {
error("Cannot open file %s", _fileName.c_str()); error("Cannot open file %s", _fileName.c_str());
} }

View file

@ -1010,7 +1010,7 @@ void ScummEngine_v60he::o60_openFile() {
// TODO / FIXME: Consider using listSavefiles to avoid unneccessary openForLoading calls // TODO / FIXME: Consider using listSavefiles to avoid unneccessary openForLoading calls
_hInFileTable[slot] = _saveFileMan->openForLoading(filename); _hInFileTable[slot] = _saveFileMan->openForLoading(filename);
if (_hInFileTable[slot] == 0) { if (_hInFileTable[slot] == 0) {
_hInFileTable[slot] = SearchMan.openFile(filename); _hInFileTable[slot] = SearchMan.createReadStreamForMember(filename);
} }
break; break;
case 2: case 2:

View file

@ -72,7 +72,7 @@ bool DXAPlayer::loadFile(const char *fileName) {
closeFile(); closeFile();
_fileStream = SearchMan.openFile(fileName); _fileStream = SearchMan.createReadStreamForMember(fileName);
if (!_fileStream) if (!_fileStream)
return false; return false;

View file

@ -66,7 +66,7 @@ int32 FlicPlayer::getFrameCount() {
bool FlicPlayer::loadFile(const char *fileName) { bool FlicPlayer::loadFile(const char *fileName) {
closeFile(); closeFile();
_fileStream = SearchMan.openFile(fileName); _fileStream = SearchMan.createReadStreamForMember(fileName);
if (!_fileStream) if (!_fileStream)
return false; return false;

View file

@ -356,7 +356,7 @@ bool SMKPlayer::loadFile(const char *fileName) {
closeFile(); closeFile();
_fileStream = SearchMan.openFile(fileName); _fileStream = SearchMan.createReadStreamForMember(fileName);
if (!_fileStream) if (!_fileStream)
return false; return false;

View file

@ -580,7 +580,7 @@ bool ThemeEngine::addBitmap(const Common::String &filename) {
// If not, try to load the bitmap via the ImageDecoder class. // If not, try to load the bitmap via the ImageDecoder class.
surf = Graphics::ImageDecoder::loadFile(filename); surf = Graphics::ImageDecoder::loadFile(filename);
if (!surf && _themeArchive) { if (!surf && _themeArchive) {
Common::SeekableReadStream *stream = _themeArchive->openFile(filename); Common::SeekableReadStream *stream = _themeArchive->createReadStreamForMember(filename);
if (stream) { if (stream) {
surf = Graphics::ImageDecoder::loadFile(*stream); surf = Graphics::ImageDecoder::loadFile(*stream);
delete stream; delete stream;
@ -1243,7 +1243,7 @@ const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &fil
const Graphics::Font *font = 0; const Graphics::Font *font = 0;
if (_themeArchive) if (_themeArchive)
stream = _themeArchive->openFile(filename); stream = _themeArchive->createReadStreamForMember(filename);
if (stream) { if (stream) {
font = Graphics::NewFont::loadFromCache(*stream); font = Graphics::NewFont::loadFromCache(*stream);
delete stream; delete stream;