[Scummvm-cvs-logs] CVS: scummvm/scumm resource_v7he.cpp,1.16,1.17
Eugene Sandulenko
sev at users.sourceforge.net
Fri Feb 4 08:35:12 CET 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27594
Modified Files:
resource_v7he.cpp
Log Message:
Some HFS dumpinf programs write files with resource fork to .bin file.
Support that. Also support separately dumped resource forks. File name for
those has .rsrc extension.
Index: resource_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v7he.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- resource_v7he.cpp 3 Feb 2005 14:43:30 -0000 1.16
+++ resource_v7he.cpp 4 Feb 2005 16:34:08 -0000 1.17
@@ -1,3 +1,4 @@
+
/* ScummVM - Scumm Interpreter
* Copyright (C) 2004-2005 The ScummVM project
*
@@ -1272,6 +1273,7 @@
int cursorsize;
int w = 0, h = 0, hotspot_x = 0, hotspot_y = 0;
int keycolor;
+ File f;
if (!_fileName[0]) // We are running for the first time
if (_vm->_heMacFileNameIndex > 0) {
@@ -1279,6 +1281,21 @@
snprintf(buf1, 128, "%s.he3", _vm->getGameName());
_vm->generateMacFileName(buf1, _fileName, 128, 0, _vm->_heMacFileNameIndex);
+
+ // Some programs write it as .bin. Try that too
+ if (!f.exists(_fileName)) {
+ strcpy(buf1, _fileName);
+ snprintf(_fileName, 128, "%s.bin", buf1);
+
+ if (!f.exists(_fileName)) {
+ // And finally check if we have dumped resource fork
+ snprintf(_fileName, 128, "%s.rsrc", buf1);
+ if (!f.exists(_fileName)) {
+ error("Cannot open file any of files '%s', '%s.bin', '%s.rsrc",
+ buf1, buf1, buf1);
+ }
+ }
+ }
}
cursorsize = extractResource(id, &cursorRes);
@@ -1331,28 +1348,26 @@
filelen = in.size();
in.read(infoHeader, MBI_INFOHDR);
- // Following should be 0 bytes
- if(infoHeader[MBI_ZERO1] != 0) return false;
-
- if(infoHeader[MBI_ZERO2] != 0) return false;
-
- if(infoHeader[MBI_ZERO3] != 0) return false;
+ // Maybe we have MacBinary?
+ if (infoHeader[MBI_ZERO1] == 0 && infoHeader[MBI_ZERO2] == 0 &&
+ infoHeader[MBI_ZERO3] == 0 && infoHeader[MBI_NAMELEN] <= MAXNAMELEN) {
- // Filename has a length range
- if(infoHeader[MBI_NAMELEN] > MAXNAMELEN) return false;
+ // Pull out fork lengths
+ data_size = READ_BE_UINT32(infoHeader + MBI_DFLEN);
+ rsrc_size = READ_BE_UINT32(infoHeader + MBI_RFLEN);
- // Pull out fork lengths
- data_size = READ_BE_UINT32(infoHeader + MBI_DFLEN);
- rsrc_size = READ_BE_UINT32(infoHeader + MBI_RFLEN);
+ data_size_pad = (((data_size + 127) >> 7) << 7);
+ rsrc_size_pad = (((rsrc_size + 127) >> 7) << 7);
- data_size_pad = (((data_size + 127) >> 7) << 7);
- rsrc_size_pad = (((rsrc_size + 127) >> 7) << 7);
+ // Length check
+ int sumlen = MBI_INFOHDR + data_size_pad + rsrc_size_pad;
- // Length check
- int sumlen = MBI_INFOHDR + data_size_pad + rsrc_size_pad;
- if(sumlen != filelen) return false;
+ if(sumlen == filelen)
+ _resOffset = MBI_INFOHDR + data_size_pad;
+ }
- _resOffset = MBI_INFOHDR + data_size_pad;
+ if (_resOffset == -1) // MacBinary check is failed
+ _resOffset = 0; // Maybe we have dumped fork?
in.seek(_resOffset);
@@ -1361,6 +1376,13 @@
_dataLength = in.readUint32BE();
_mapLength = in.readUint32BE();
+ // do sanity check
+ if (_dataOffset >= filelen || _mapOffset >= filelen ||
+ _dataLength + _mapLength > filelen) {
+ _resOffset = -1;
+ return false;
+ }
+
debug(7, "got header: data %d [%d] map %d [%d]",
_dataOffset, _dataLength, _mapOffset, _mapLength);
More information about the Scummvm-git-logs
mailing list