[Scummvm-cvs-logs] SF.net SVN: scummvm: [32476] scummvm/trunk/common

sev at users.sourceforge.net sev at users.sourceforge.net
Sun Jun 1 23:10:29 CEST 2008


Revision: 32476
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32476&view=rev
Author:   sev
Date:     2008-06-01 14:10:29 -0700 (Sun, 01 Jun 2008)

Log Message:
-----------
Implement file fallback for archives

Modified Paths:
--------------
    scummvm/trunk/common/unarj.cpp
    scummvm/trunk/common/unarj.h

Modified: scummvm/trunk/common/unarj.cpp
===================================================================
--- scummvm/trunk/common/unarj.cpp	2008-06-01 20:58:05 UTC (rev 32475)
+++ scummvm/trunk/common/unarj.cpp	2008-06-01 21:10:29 UTC (rev 32476)
@@ -78,6 +78,7 @@
 ArjFile::ArjFile() {
 	InitCRC();
 	_isOpen = false;
+	_fallBack = false;
 }
 
 ArjFile::~ArjFile() {
@@ -234,6 +235,15 @@
 
 	_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 @@
 void ArjFile::close() {
 	_isOpen = false;
 
-	delete _uncompressed;
+	if (_fallBack) {
+		_currArchive.close();
+	} else {
+		delete _uncompressed;
+	}
+
 	_uncompressed = NULL;
 
 	free(_uncompressedData);

Modified: scummvm/trunk/common/unarj.h
===================================================================
--- scummvm/trunk/common/unarj.h	2008-06-01 20:58:05 UTC (rev 32475)
+++ scummvm/trunk/common/unarj.h	2008-06-01 21:10:29 UTC (rev 32476)
@@ -106,6 +106,8 @@
 	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 @@
 	bool isOpen() { return _isOpen; }
 
 private:
+	bool _fallBack;
+
 	File _currArchive;
 	Array<ArjHeader *> _headers;
 	ArjFilesMap _fileMap;
@@ -128,7 +132,7 @@
 	byte *_compressedData;
 	MemoryWriteStream *_outstream;
 	MemoryReadStream *_compressed;
-	MemoryReadStream *_uncompressed;
+	SeekableReadStream *_uncompressed;
 
 	bool _isOpen;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list