diff options
author | Eugene Sandulenko | 2008-06-01 21:10:29 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2008-06-01 21:10:29 +0000 |
commit | 452d46b3bf6a3c77bc4583a56e7dc5e7a4ad385b (patch) | |
tree | de2d0f1a12107ee3c33b514cdcb5fb11ca3f2f73 | |
parent | ba5cebfaf8cdddef3bd1d814106935ab305bb410 (diff) | |
download | scummvm-rg350-452d46b3bf6a3c77bc4583a56e7dc5e7a4ad385b.tar.gz scummvm-rg350-452d46b3bf6a3c77bc4583a56e7dc5e7a4ad385b.tar.bz2 scummvm-rg350-452d46b3bf6a3c77bc4583a56e7dc5e7a4ad385b.zip |
Implement file fallback for archives
svn-id: r32476
-rw-r--r-- | common/unarj.cpp | 17 | ||||
-rw-r--r-- | common/unarj.h | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/common/unarj.cpp b/common/unarj.cpp index 58f326c1ac..57673341f7 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -78,6 +78,7 @@ static uint32 GetCRC(byte *data, int len) { ArjFile::ArjFile() { InitCRC(); _isOpen = false; + _fallBack = false; } ArjFile::~ArjFile() { @@ -234,6 +235,15 @@ bool ArjFile::open(const Common::String &filename, AccessMode mode) { _isOpen = false; + if (_fallBack) { + _currArchive.open(filename); + if (_currArchive.isOpen()) { + _isOpen = true; + _uncompressed = &_currArchive; + return true; + } + } + if (!_fileMap.contains(filename)) return false; @@ -279,7 +289,12 @@ bool ArjFile::open(const Common::String &filename, AccessMode mode) { void ArjFile::close() { _isOpen = false; - delete _uncompressed; + if (_fallBack) { + _currArchive.close(); + } else { + delete _uncompressed; + } + _uncompressed = NULL; free(_uncompressedData); diff --git a/common/unarj.h b/common/unarj.h index 289ab52ad0..b015999671 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -106,6 +106,8 @@ public: ArjFile(); ~ArjFile(); + void enableFallback(bool val) { _fallBack = val; } + void registerArchive(const String &filename); bool open(const Common::String &filename, AccessMode mode = kFileReadMode); @@ -119,6 +121,8 @@ public: bool isOpen() { return _isOpen; } private: + bool _fallBack; + File _currArchive; Array<ArjHeader *> _headers; ArjFilesMap _fileMap; @@ -128,7 +132,7 @@ private: byte *_compressedData; MemoryWriteStream *_outstream; MemoryReadStream *_compressed; - MemoryReadStream *_uncompressed; + SeekableReadStream *_uncompressed; bool _isOpen; |