[Scummvm-cvs-logs] SF.net SVN: scummvm:[46373] tools/branches/gsoc2009-gui
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Dec 14 00:46:10 CET 2009
Revision: 46373
http://scummvm.svn.sourceforge.net/scummvm/?rev=46373&view=rev
Author: fingolfin
Date: 2009-12-13 23:46:09 +0000 (Sun, 13 Dec 2009)
Log Message:
-----------
TOOLS: Rename&merge File::read & readN methods to read_throwsOnError & read_noThrow (these should be changed again later, but for now this helps me not getting confused ;)
Modified Paths:
--------------
tools/branches/gsoc2009-gui/common/file.cpp
tools/branches/gsoc2009-gui/common/file.h
tools/branches/gsoc2009-gui/compress.cpp
tools/branches/gsoc2009-gui/compress_agos.cpp
tools/branches/gsoc2009-gui/compress_gob.cpp
tools/branches/gsoc2009-gui/compress_kyra.cpp
tools/branches/gsoc2009-gui/compress_queen.cpp
tools/branches/gsoc2009-gui/compress_saga.cpp
tools/branches/gsoc2009-gui/compress_scumm_bun.cpp
tools/branches/gsoc2009-gui/compress_scumm_san.cpp
tools/branches/gsoc2009-gui/compress_scumm_sou.cpp
tools/branches/gsoc2009-gui/compress_sword1.cpp
tools/branches/gsoc2009-gui/compress_sword2.cpp
tools/branches/gsoc2009-gui/compress_tinsel.cpp
tools/branches/gsoc2009-gui/compress_touche.cpp
tools/branches/gsoc2009-gui/compress_tucker.cpp
tools/branches/gsoc2009-gui/degob.cpp
tools/branches/gsoc2009-gui/dekyra.cpp
tools/branches/gsoc2009-gui/desword2.cpp
tools/branches/gsoc2009-gui/encode_dxa.cpp
tools/branches/gsoc2009-gui/extract_agos.cpp
tools/branches/gsoc2009-gui/extract_cine.cpp
tools/branches/gsoc2009-gui/extract_gob_stk.cpp
tools/branches/gsoc2009-gui/extract_parallaction.cpp
tools/branches/gsoc2009-gui/extract_scumm_mac.cpp
tools/branches/gsoc2009-gui/extract_t7g_mac.cpp
tools/branches/gsoc2009-gui/kyra_ins.cpp
tools/branches/gsoc2009-gui/kyra_pak.cpp
tools/branches/gsoc2009-gui/sci/scipack.cpp
tools/branches/gsoc2009-gui/utils/voc.cpp
tools/branches/gsoc2009-gui/utils/wave.cpp
Modified: tools/branches/gsoc2009-gui/common/file.cpp
===================================================================
--- tools/branches/gsoc2009-gui/common/file.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/common/file.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -346,32 +346,18 @@
return ret;
}
-void File::read(void *data, size_t elementSize, size_t elementCount) {
- if (!_file)
- throw FileException("File is not open");
- if ((_mode & FILEMODE_READ) == 0)
- throw FileException("Tried to read from file opened in write mode (" + _name.getFullPath() + ")");
-
- size_t data_read = fread(data, elementSize, elementCount, _file);
- if (data_read != elementCount)
+void File::read_throwsOnError(void *dataPtr, size_t dataSize) {
+ size_t data_read = read_noThrow(dataPtr, dataSize);
+ if (data_read != dataSize)
throw FileException("Read beyond the end of file (" + _name.getFullPath() + ")");
}
-size_t File::readN(void *data, size_t elementSize, size_t elementCount) {
+size_t File::read_noThrow(void *dataPtr, size_t dataSize) {
if (!_file)
throw FileException("File is not open");
if ((_mode & FILEMODE_READ) == 0)
throw FileException("Tried to read from file opened in write mode (" + _name.getFullPath() + ")");
- return fread(data, elementSize, elementCount, _file);
-}
-
-size_t File::read(void *dataPtr, size_t dataSize) {
- if (!_file)
- throw FileException("File is not open");
- if ((_mode & FILEMODE_READ) == 0)
- throw FileException("Tried to read from file opened in write mode (" + _name.getFullPath() + ")");
-
return fread(dataPtr, 1, dataSize, _file);
}
Modified: tools/branches/gsoc2009-gui/common/file.h
===================================================================
--- tools/branches/gsoc2009-gui/common/file.h 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/common/file.h 2009-12-13 23:46:09 UTC (rev 46373)
@@ -260,31 +260,20 @@
* Works the same way as fread, but throws on error or if it could
* not read all elements.
*
- * @param data Where to put the read data
- * @param elementSize the size of one element (in bytes)
- * @param elementCount the number of elements to read
+ * @param dataPtr pointer to a buffer into which the data is read
+ * @param dataSize number of bytes to be read
*/
- void read(void *data, size_t elementSize, size_t elementCount);
+ void read_throwsOnError(void *dataPtr, size_t dataSize);
/**
* Works the same way as fread, does NOT throw if it could not read all elements
* still throws if file is not open.
*
- * @param data Where to put the read data
- * @param elementSize the size of one element (in bytes)
- * @param elementCount the number of elements to read
- * @return number of bytes read
- */
- size_t readN(void *data, size_t elementSize, size_t elementCount);
-
- /**
- * Read on a shorter form, does not throw (like readN)
- *
* @param dataPtr pointer to a buffer into which the data is read
* @param dataSize number of bytes to be read
* @return the number of bytes which were actually read.
*/
- size_t read(void *dataPtr, size_t dataSize);
+ size_t read_noThrow(void *dataPtr, size_t dataSize);
/**
* Reads a full string, until NULL or EOF
Modified: tools/branches/gsoc2009-gui/compress.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -247,7 +247,7 @@
File inputRaw(inname, "rb");
length = inputRaw.size();
rawData = (char *)malloc(length);
- inputRaw.read(rawData, 1, length);
+ inputRaw.read_throwsOnError(rawData, length);
encodeRaw(rawData, length, rawSamplerate, outname, compmode);
@@ -274,7 +274,7 @@
length = inputWav.readUint32LE();
wavData = (char *)malloc(length);
- inputWav.read(wavData, 1, length);
+ inputWav.read_throwsOnError(wavData, length);
setRawAudioType(true, numChannels == 2, (uint8)bitsPerSample);
encodeRaw(wavData, length, sampleRate, outname, compmode);
@@ -572,7 +572,7 @@
/* Copy the WAV data to a temporary file */
File f(outName, "wb");
while (length > 0) {
- size = input.readN(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : length);
+ size = input.read_noThrow(fbuf, length > sizeof(fbuf) ? sizeof(fbuf) : length);
if (size <= 0)
break;
length -= (int)size;
@@ -648,7 +648,7 @@
/* Copy the raw data to a temporary file */
while (length > 0) {
- size = input.readN(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : (uint32)length);
+ size = input.read_noThrow(fbuf, length > sizeof(fbuf) ? sizeof(fbuf) : (uint32)length);
if (size <= 0) {
break;
Modified: tools/branches/gsoc2009-gui/compress_agos.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_agos.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_agos.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -48,12 +48,12 @@
File outputFile(_outputPath, "wb");
_input.open(TEMP_IDX, "rb");
- while ((size = _input.readN(fbuf, 1, 2048)) > 0) {
+ while ((size = _input.read_noThrow(fbuf, 2048)) > 0) {
outputFile.write(fbuf, size);
}
_input.open(TEMP_DAT, "rb");
- while ((size = _input.readN(fbuf, 1, 2048)) > 0) {
+ while ((size = _input.read_noThrow(fbuf, 2048)) > 0) {
outputFile.write(fbuf, size);
}
@@ -72,7 +72,7 @@
int CompressAgos::get_offsets(size_t maxcount, uint32 filenums[], uint32 offsets[]) {
for (size_t i = 0; i < maxcount; i++) {
char buf[8];
- _input.read(buf, 1, 8);
+ _input.read_throwsOnError(buf, 8);
if (!memcmp(buf, "Creative", 8) || !memcmp(buf, "RIFF", 4)) {
return i;
}
@@ -108,7 +108,7 @@
_input.seek(offset, SEEK_SET);
- _input.read(buf, 1, 8);
+ _input.read_throwsOnError(buf, 8);
if (!memcmp(buf, "Creative", 8)) {
print("VOC found (pos = %d) :\n", offset);
_input.seek(18, SEEK_CUR);
@@ -124,7 +124,7 @@
sprintf(outname, "%s", tempEncoded);
File f(outname, "rb");
tot_size = 0;
- while ((size = f.readN(fbuf, 1, 2048)) > 0) {
+ while ((size = f.read_noThrow(fbuf, 2048)) > 0) {
tot_size += size;
_output_snd.write(fbuf, size);
}
Modified: tools/branches/gsoc2009-gui/compress_gob.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_gob.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_gob.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -310,7 +310,7 @@
uint32 tmpSize = 0;
do {
- count = src.readN(buffer, 1, 4096);
+ count = src.read_noThrow(buffer, 4096);
stk.write(buffer, count);
tmpSize += count;
} while (count == 4096);
@@ -342,7 +342,7 @@
memset(dico, 0x20, 4114);
memset(unpacked, 0, size + 1);
- src.read(unpacked, 1, size);
+ src.read_throwsOnError(unpacked, size);
writeBuffer[0] = size & 0xFF;
writeBuffer[1] = size >> 8;
@@ -440,8 +440,8 @@
src2.open(compChunk->name, "rb");
do {
- readCount = src1.readN(buf1, 1, 4096);
- src2.readN(buf2, 1, 4096);
+ readCount = src1.read_noThrow(buf1, 4096);
+ src2.read_noThrow(buf2, 4096);
for (int i = 0; checkFl & (i < readCount); i++)
if (buf1[i] != buf2[i])
checkFl = false;
Modified: tools/branches/gsoc2009-gui/compress_kyra.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_kyra.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_kyra.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -145,7 +145,7 @@
if (size == outSize) {
int readSize = size;
while (readSize > 0) {
- int read = in.readN(outputBuffer, 1, readSize);
+ int read = in.read_noThrow(outputBuffer, readSize);
if (read <= 0)
error("[1] Couldn't read data");
readSize -= read;
@@ -163,7 +163,7 @@
int readSize = size;
while (readSize > 0) {
- int read = in.readN(inputBuffer, 1, readSize);
+ int read = in.read_noThrow(inputBuffer, readSize);
if (read <= 0)
error("[2] Couldn't read data");
readSize -= read;
Modified: tools/branches/gsoc2009-gui/compress_queen.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_queen.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_queen.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -121,7 +121,7 @@
uint32 numRead;
while (amount > 0) {
- numRead = in.readN(fBuf, 1, amount > 2048 ? 2048 : amount);
+ numRead = in.read_noThrow(fBuf, amount > 2048 ? 2048 : amount);
if (numRead <= 0) {
break;
}
@@ -190,7 +190,7 @@
inputTbl.open(inpath, "rb");
size = inputData.size();
- inputTbl.read(tmp, 1, 4);
+ inputTbl.read_throwsOnError(tmp, 4);
tmp[4] = '\0';
if (memcmp(tmp, "QTBL", 4)) {
@@ -223,7 +223,7 @@
prevOffset = outputData.pos();
/* Read entry */
- inputTbl.read(_entry.filename, 1, 12);
+ inputTbl.read_throwsOnError(_entry.filename, 12);
_entry.filename[12] = '\0';
_entry.bundle = inputTbl.readByte();
_entry.offset = inputTbl.readUint32BE();
Modified: tools/branches/gsoc2009-gui/compress_saga.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_saga.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_saga.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -186,7 +186,7 @@
if (!tempf.isOpen())
error("Unable to open %s", fromFileName);
- while ((size = tempf.readN(fbuf, 1, sizeof(fbuf))) > 0) {
+ while ((size = tempf.read_noThrow(fbuf, sizeof(fbuf))) > 0) {
outputFile.write(fbuf, size);
}
size = tempf.pos();
@@ -201,7 +201,7 @@
if (!tempf.isOpen())
error("Unable to open %s", toFileName);
while (inputSize > 0) {
- size = inputFile.readN(fbuf, 1, inputSize > sizeof(fbuf) ? sizeof(fbuf) : inputSize);
+ size = inputFile.read_noThrow(fbuf, inputSize > sizeof(fbuf) ? sizeof(fbuf) : inputSize);
if (size == 0) {
error("Unable to copy file");
}
Modified: tools/branches/gsoc2009-gui/compress_scumm_bun.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_bun.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_scumm_bun.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -739,7 +739,7 @@
for (i = 0; i < numCompItems; i++) {
compInput[compTable[i].size] = 0;
input.seek(_bundleTable[index].offset + compTable[i].offset, SEEK_SET);
- input.read(compInput, 1, compTable[i].size);
+ input.read_throwsOnError(compInput, compTable[i].size);
int outputSize = decompressCodec(compTable[i].codec, compInput, compOutput, compTable[i].size);
assert(outputSize <= 0x2000);
memcpy(compFinal + finalSize, compOutput, outputSize);
@@ -916,7 +916,7 @@
size = cmpFile.pos();
cmpFile.seek(0, SEEK_SET);
byte *tmpBuf = (byte *)malloc(size);
- cmpFile.read(tmpBuf, size, 1);
+ cmpFile.read_throwsOnError(tmpBuf, size);
cmpFile.close();
unlink(tmpPath);
Modified: tools/branches/gsoc2009-gui/compress_scumm_san.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_san.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_scumm_san.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -173,7 +173,7 @@
int bsize = size - 18;
byte output_data[0x1000];
byte *src = (byte *)malloc(bsize);
- input.read(src, bsize, 1);
+ input.read_throwsOnError(src, bsize);
sprintf(tmpPath, "%s/%s.wav", outputDir, inputFilename);
decompressComiIACT(tmpPath, output_data, src, bsize);
@@ -219,7 +219,7 @@
int fileSize = _audioTracks[l].file.pos();
_audioTracks[l].file.seek(0, SEEK_SET);
byte *audioBuf = (byte *)malloc(fileSize);
- _audioTracks[l].file.read(audioBuf, fileSize, 1);
+ _audioTracks[l].file.read_throwsOnError(audioBuf, fileSize);
_audioTracks[l].file.close();
int outputSize = fileSize;
@@ -350,13 +350,13 @@
int fileSize = _audioTracks[l].file.pos();
_audioTracks[l].file.seek(0, SEEK_SET);
byte *tmpBuf = (byte *)malloc(fileSize);
- _audioTracks[l].file.read(tmpBuf, fileSize, 1);
+ _audioTracks[l].file.read_throwsOnError(tmpBuf, fileSize);
_audioTracks[l].file.close();
unlink(filename);
byte *wavBuf = (byte *)malloc(fileSize);
wavFile.seek(44 + (frameAudioSize * _audioTracks[l].animFrame), SEEK_SET);
- wavFile.read(wavBuf, fileSize, 1);
+ wavFile.read_throwsOnError(wavBuf, fileSize);
int offset = 0;
for (z = 0; z < _audioTracks[l].countFrames; z++) {
@@ -510,7 +510,7 @@
}
}
byte *buffer = (byte *)malloc(size);
- input.read(buffer, size, 1);
+ input.read_throwsOnError(buffer, size);
audioTrack->file.write(buffer, size);
free(buffer);
audioTrack->volumes[index] = volume;
Modified: tools/branches/gsoc2009-gui/compress_scumm_sou.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_scumm_sou.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_scumm_sou.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -52,12 +52,12 @@
_output_idx.writeUint32BE((uint32)idx_size);
File in(TEMP_IDX, "rb");
- while ((size = in.readN(buf, 1, 2048)) > 0) {
+ while ((size = in.read_noThrow(buf, 2048)) > 0) {
_output_idx.write(buf, size);
}
in.open(TEMP_DAT, "rb");
- while ((size = in.readN(buf, 1, 2048)) > 0) {
+ while ((size = in.read_noThrow(buf, 2048)) > 0) {
_output_idx.write(buf, size);
}
in.close();
@@ -87,7 +87,7 @@
try {
/* Scan for the VCTL header */
- _input.read(buf, 1, 4);
+ _input.read_throwsOnError(buf, 4);
/* The demo (snmdemo) and floppy version of Sam & Max use VTTL */
while (memcmp(buf, "VCTL", 4)&&memcmp(buf, "VTTL", 4)) {
pos++;
@@ -110,7 +110,7 @@
tags--;
}
- _input.read(buf, 1, 8);
+ _input.read_throwsOnError(buf, 8);
if (!memcmp(buf, "Creative", 8))
_input.seek(18, SEEK_CUR);
else if (!memcmp(buf, "VTLK", 4))
@@ -125,7 +125,7 @@
/* Append the converted data to the master output file */
File f(tempEncoded, "rb");
tot_size = 0;
- while ((size = f.readN(buf, 1, 2048)) > 0) {
+ while ((size = f.read_noThrow(buf, 2048)) > 0) {
tot_size += size;
_output_snd.write(buf, size);
}
@@ -161,7 +161,7 @@
_output_snd.open(TEMP_DAT, "wb");
/* Get the 'SOU ....' header */
- _input.read(buf, 1, 8);
+ _input.read_throwsOnError(buf, 8);
if (strncmp(buf, f_hdr, 8)) {
error("Bad SOU");
}
Modified: tools/branches/gsoc2009-gui/compress_sword1.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_sword1.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_sword1.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -312,7 +312,7 @@
int16 length, cnt;
uint8 *fBuf = (uint8 *)malloc(cSize);
clu.seek(idx, SEEK_SET);
- clu.read(fBuf, 1, cSize);
+ clu.read_throwsOnError(fBuf, cSize);
while ((READ_BE_UINT32(fBuf + headerPos) != 'data') && (headerPos < 100))
headerPos++;
@@ -361,7 +361,7 @@
*resSize = size = temp.pos();
resBuf = (uint8*)malloc(size);
temp.seek(0, SEEK_SET);
- temp.read(resBuf, 1, size);
+ temp.read_throwsOnError(resBuf, size);
return resBuf;
}
Modified: tools/branches/gsoc2009-gui/compress_sword2.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_sword2.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_sword2.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -34,7 +34,7 @@
orig_length = length = f2.size();
while (length > 0) {
- size = f2.readN(fbuf, 1, length > sizeof(fbuf) ? sizeof(fbuf) : length);
+ size = f2.read_noThrow(fbuf, length > sizeof(fbuf) ? sizeof(fbuf) : length);
if (size <= 0) {
break;
}
Modified: tools/branches/gsoc2009-gui/compress_tinsel.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_tinsel.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_tinsel.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -75,7 +75,7 @@
curFileHandle.open(TEMP_RAW, "wb");
copyLeft = sampleSize;
while (copyLeft > 0) {
- doneRead = _input_smp.readN(buffer, 1, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
+ doneRead = _input_smp.read_noThrow(buffer, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
if (doneRead <= 0)
break;
copyLeft -= (int)doneRead;
@@ -96,7 +96,7 @@
_output_smp.writeUint32LE(copyLeft);
// Write actual data
while (copyLeft > 0) {
- doneRead = curFileHandle.readN(buffer, 1, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
+ doneRead = curFileHandle.read_noThrow(buffer, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
if (doneRead <= 0)
break;
copyLeft -= (int)doneRead;
@@ -159,7 +159,7 @@
return;
}
- _input_smp.read(inBuffer, 1, sampleSize);
+ _input_smp.read_throwsOnError(inBuffer, sampleSize);
// 1 channel, 22050 rate, block align 24,
blockAlign = 24; // Fixed for Tinsel 6-bit
@@ -243,7 +243,7 @@
_output_smp.writeUint32LE(copyLeft);
// Write actual data
while (copyLeft > 0) {
- doneRead = curFileHandle.readN(buffer, 1, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
+ doneRead = curFileHandle.read_noThrow(buffer, copyLeft > sizeof(buffer) ? sizeof(buffer) : copyLeft);
if (doneRead <= 0)
break;
copyLeft -= (int)doneRead;
Modified: tools/branches/gsoc2009-gui/compress_touche.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_touche.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_touche.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -78,7 +78,7 @@
offs_table[i] = 0;
} else {
input.seek(offs_table[i], SEEK_SET);
- input.read(buf, 1, 8);
+ input.read_throwsOnError(buf, 8);
if (memcmp(buf, "Creative", 8) != 0) {
error("Invalid VOC data found");
@@ -93,7 +93,7 @@
size_table[i] = 0;
- while ((size = temp.readN(buf, 1, 2048)) > 0) {
+ while ((size = temp.read_noThrow(buf, 2048)) > 0) {
output.write(buf, size);
size_table[i] += size;
}
Modified: tools/branches/gsoc2009-gui/compress_tucker.cpp
===================================================================
--- tools/branches/gsoc2009-gui/compress_tucker.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/compress_tucker.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -55,7 +55,7 @@
int sz, compress_sz = 0;
File input_temp(tempEncoded, "rb");
- while ((sz = input_temp.readN(buf, 1, sizeof(buf))) > 0) {
+ while ((sz = input_temp.read_noThrow(buf, sizeof(buf))) > 0) {
if ((sz = output.write(buf, sz)) > 0) {
compress_sz += sz;
}
@@ -66,7 +66,7 @@
int CompressTucker::compress_file_wav(File &input, File &output) {
char buf[8];
- if (input.readN(buf, 1, 8) == 8 && memcmp(buf, "RIFF", 4) == 0) {
+ if (input.read_noThrow(buf, 8) == 8 && memcmp(buf, "RIFF", 4) == 0) {
extractAndEncodeWAV(TEMP_WAV, input, _format);
return append_compress_file(output);
}
Modified: tools/branches/gsoc2009-gui/degob.cpp
===================================================================
--- tools/branches/gsoc2009-gui/degob.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/degob.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -150,7 +150,7 @@
size = f.size();
byte *data = new byte[size];
- f.read(data, size);
+ f.read_noThrow(data, size);
return data;
}
Modified: tools/branches/gsoc2009-gui/dekyra.cpp
===================================================================
--- tools/branches/gsoc2009-gui/dekyra.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/dekyra.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -194,7 +194,7 @@
scriptData->fileSize = size;
uint8 *data = new uint8[size];
assert(data);
- if (size != scriptFile.read(data, size)) {
+ if (size != scriptFile.read_noThrow(data, size)) {
delete [] data;
error("couldn't read all bytes from file '%s'", filename);
return false;
Modified: tools/branches/gsoc2009-gui/desword2.cpp
===================================================================
--- tools/branches/gsoc2009-gui/desword2.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/desword2.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -303,7 +303,7 @@
}
in.seek(9, SEEK_CUR);
- in.read(name, 1, sizeof(name));
+ in.read_throwsOnError(name, sizeof(name));
printf("\"%s\"\n", name);
Modified: tools/branches/gsoc2009-gui/encode_dxa.cpp
===================================================================
--- tools/branches/gsoc2009-gui/encode_dxa.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/encode_dxa.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -649,7 +649,7 @@
File fp(filename, "rb");
- fp.read(header, 1, 8);
+ fp.read_throwsOnError(header, 8);
if (png_sig_cmp(header, 0, 8))
return 1;
@@ -720,7 +720,7 @@
scaleMode = S_NONE;
char buf[4];
- smk.read(buf, 1, 4);
+ smk.read_throwsOnError(buf, 4);
if (!memcmp(buf, "BIK", 3)) {
// Skip file size
smk.readUint32LE();
Modified: tools/branches/gsoc2009-gui/extract_agos.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_agos.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_agos.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -189,7 +189,7 @@
void *mem = malloc(file.size());
// Read data
- file.read(mem, 1, _filelen);
+ file.read_throwsOnError(mem, _filelen);
return mem;
}
Modified: tools/branches/gsoc2009-gui/extract_cine.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_cine.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_cine.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -179,7 +179,7 @@
unsigned int entrySize = file.readUint16BE(); // How many bytes per entry?
assert(entrySize == 0x1e);
while (entryCount--) {
- file.read(fileName, 14, 1);
+ file.read_throwsOnError(fileName, 14);
fileName[14] = '\0';
Filename outPath(_outputPath);
@@ -202,7 +202,7 @@
uint8 *packedData = (uint8 *)calloc(packedSize, 1);
assert(data);
assert(packedData);
- file.read(packedData, packedSize, 1);
+ file.read_throwsOnError(packedData, packedSize);
bool status = true;
if (packedSize != unpackedSize) {
CineUnpacker cineUnpacker;
@@ -253,7 +253,7 @@
uint32 unpackedSize, packedSize;
{
char header[8];
- f.read(header, 8, 1);
+ f.read_throwsOnError(header, 8);
if (memcmp(header, "ABASECP", 7) == 0) {
unpackedSize = f.readUint32BE();
packedSize = f.readUint32BE();
@@ -266,7 +266,7 @@
assert(unpackedSize >= packedSize);
uint8 *buf = (uint8 *)calloc(unpackedSize, 1);
assert(buf);
- f.read(buf, packedSize, 1);
+ f.read_throwsOnError(buf, packedSize);
if (packedSize != unpackedSize) {
CineUnpacker cineUnpacker;
Modified: tools/branches/gsoc2009-gui/extract_gob_stk.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_gob_stk.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_gob_stk.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -76,7 +76,7 @@
gobConf.open(_outputPath.getFullPath(), "w");
gobConf.printf("%s\n", inpath.getFullName().c_str());
- stk.read(signature, 1, 6);
+ stk.read_throwsOnError(signature, 6);
if (strncmp(signature, "STK2.1", 6) == 0) {
print("Signature of new STK format (STK 2.1) detected in file \"%s\"", inpath.getFullPath().c_str());
@@ -104,7 +104,7 @@
char *fakeTotPtr;
while (numDataChunks-- > 0) {
- stk.read(curChunk->name, 1, 13);
+ stk.read_throwsOnError(curChunk->name, 13);
curChunk->size = stk.readUint32LE();
curChunk->offset = stk.readUint32LE();
@@ -153,12 +153,12 @@
// + 08 bytes : Name / acronym of STK/ITK creator
// + 04 bytes : Start position of Filenames Section
- stk.read(buffer, 1, 14);
+ stk.read_throwsOnError(buffer, 14);
buffer[14] = '\0';
sprintf(debugStr, "File generated on %s by ", buffer);
- stk.read(buffer, 1, 8);
+ stk.read_throwsOnError(buffer, 8);
buffer[8] = '\0';
strcat(debugStr, buffer);
@@ -198,11 +198,11 @@
stk.seek(miscPos + (cpt * 61), SEEK_SET);
filenamePos = stk.readUint32LE();
- stk.read(buffer, 1, 36);
+ stk.read_throwsOnError(buffer, 36);
curChunk->size = stk.readUint32LE();
decompSize = stk.readUint32LE();
- stk.read(buffer, 1, 5);
+ stk.read_throwsOnError(buffer, 5);
filePos = stk.readUint32LE();
compressFlag = stk.readUint32LE();
@@ -264,7 +264,7 @@
byte *data = new byte[curChunk->size];
- stk.read(data, curChunk->size, 1);
+ stk.read_throwsOnError(data, curChunk->size);
try {
if (curChunk->packed) {
Modified: tools/branches/gsoc2009-gui/extract_parallaction.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_parallaction.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_parallaction.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -80,7 +80,7 @@
byte *srcData = (byte *)malloc(srcSize);
_file.seek(srcOffset, SEEK_SET);
- _file.read(srcData, 1, srcSize);
+ _file.read_throwsOnError(srcData, srcSize);
if (isPackedSubfile(srcData)) {
_fileSize = getSizeOfPackedSubfile(srcData, srcSize);
@@ -122,7 +122,7 @@
strcpy(_name, filename);
_file.seek(ARCHIVE_HEADER_SIZE, SEEK_SET);
- _file.read(_names, maxEntries + 1, ARCHIVE_FILENAME_LEN);
+ _file.read_throwsOnError(_names, (maxEntries + 1) * ARCHIVE_FILENAME_LEN);
uint32 i;
for (i = 0; i < maxEntries; i++) {
Modified: tools/branches/gsoc2009-gui/extract_scumm_mac.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_scumm_mac.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_scumm_mac.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -91,7 +91,7 @@
file_off = ifp.readUint32BE();
file_len = ifp.readUint32BE();
- ifp.read(file_name, 0x20, 1);
+ ifp.read_throwsOnError(file_name, 0x20);
if (!file_name[0])
error("\'%s\'. file has no name.", inpath.getFullPath().c_str());
@@ -138,7 +138,7 @@
error("Could not allocate %ld bytes of memory.", file_len);
}
- ifp.read(buf, 1, file_len);
+ ifp.read_throwsOnError(buf, file_len);
ofp.write(buf, file_len);
free(buf);
}
Modified: tools/branches/gsoc2009-gui/extract_t7g_mac.cpp
===================================================================
--- tools/branches/gsoc2009-gui/extract_t7g_mac.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/extract_t7g_mac.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -43,7 +43,7 @@
std::string ExtractT7GMac::readString(File &infile) {
byte len = infile.readByte();
char *name = new char[len + 1];
- infile.read(name, len, 1);
+ infile.read_throwsOnError(name, len);
name[len] = 0;
return name;
}
@@ -59,7 +59,7 @@
try {
// Dump the resource to the output file
File out(name, "wb");
- infile.read(buf, 1, fileSize);
+ infile.read_throwsOnError(buf, fileSize);
out.write(buf, fileSize);
} catch (...) {
delete[] buf;
@@ -111,7 +111,7 @@
infile.seek(offsetResTypes + 2 + 8 * i, SEEK_SET);
// Read the resource type name
- infile.read(resType, 4, 1);
+ infile.read_throwsOnError(resType, 4);
switch (READ_BE_UINT32(resType)) {
case MKID_BE('csnd'):
case MKID_BE('snd '):
Modified: tools/branches/gsoc2009-gui/kyra_ins.cpp
===================================================================
--- tools/branches/gsoc2009-gui/kyra_ins.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/kyra_ins.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -557,7 +557,7 @@
} else {
if (inPart2) {
file.seek(1, SEEK_SET);
- file.read(inbuffer + inPart1, 1, inPart2);
+ file.read_throwsOnError(inbuffer + inPart1, inPart2);
inPart2 = 0;
exp.process(outbuffer, inbuffer, outsize, insize);
delete[] inbuffer;
@@ -601,10 +601,10 @@
snprintf(filename, 64, "%s.%03d", _baseFilename, i+1);
File file2(filename, "rb");
- file.read(hdr, 1, m);
- file2.read(hdr + m , 1, b);
+ file.read_throwsOnError(hdr, m);
+ file2.read_throwsOnError(hdr + m , b);
} else {
- file.read(hdr, 1, 42);
+ file.read_throwsOnError(hdr, 42);
}
uint32 id = READ_LE_UINT32(hdr);
@@ -633,9 +633,9 @@
// this is for files that are split between two archive files
inPart1 = size - pos;
inPart2 = insize - inPart1;
- file.read(inbuffer, 1, inPart1);
+ file.read_throwsOnError(inbuffer, inPart1);
} else {
- file.read(inbuffer, 1, insize);
+ file.read_throwsOnError(inbuffer, insize);
inPart2 = 0;
exp.process(outbuffer, inbuffer, outsize, insize);
delete[] inbuffer;
Modified: tools/branches/gsoc2009-gui/kyra_pak.cpp
===================================================================
--- tools/branches/gsoc2009-gui/kyra_pak.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/kyra_pak.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -88,7 +88,7 @@
uint8 *buffer = new uint8[filesize];
assert(buffer);
- pakfile.read(buffer, filesize, 1);
+ pakfile.read_throwsOnError(buffer, filesize);
const char *currentName = 0;
@@ -189,7 +189,7 @@
uint32 filesize = f.size();
uint8 *data = new uint8[filesize];
assert(data);
- f.read(data, 1, filesize);
+ f.read_throwsOnError(data, filesize);
return addFile(name, data, filesize);
}
Modified: tools/branches/gsoc2009-gui/sci/scipack.cpp
===================================================================
--- tools/branches/gsoc2009-gui/sci/scipack.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/sci/scipack.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -167,7 +167,7 @@
write_uint16(resource_000, 0);
do {
- j = read(fd, buf, COPY_BLOCK_SIZE);
+ j = read_noThrow(fd, buf, COPY_BLOCK_SIZE);
write(resource_000, buf, j);
} while (j == COPY_BLOCK_SIZE);
close(fd);
Modified: tools/branches/gsoc2009-gui/utils/voc.cpp
===================================================================
--- tools/branches/gsoc2009-gui/utils/voc.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/utils/voc.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -43,14 +43,14 @@
byte *loadVOCFromStream(File &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
VocFileHeader fileHeader;
- if (stream.read(&fileHeader, 8) != 8)
+ if (stream.read_noThrow(&fileHeader, 8) != 8)
goto invalid;
if (!memcmp(&fileHeader, "VTLK", 4)) {
- if (stream.read(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader))
+ if (stream.read_noThrow(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader))
goto invalid;
} else if (!memcmp(&fileHeader, "Creative", 8)) {
- if (stream.read(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8)
+ if (stream.read_noThrow(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8)
goto invalid;
} else {
invalid:;
@@ -96,7 +96,7 @@
} else {
ret_sound = (byte *)malloc(len);
}
- stream.read(ret_sound + size, len);
+ stream.read_noThrow(ret_sound + size, len);
size += len;
begin_loop = size;
end_loop = size;
Modified: tools/branches/gsoc2009-gui/utils/wave.cpp
===================================================================
--- tools/branches/gsoc2009-gui/utils/wave.cpp 2009-12-13 22:52:38 UTC (rev 46372)
+++ tools/branches/gsoc2009-gui/utils/wave.cpp 2009-12-13 23:46:09 UTC (rev 46373)
@@ -31,7 +31,7 @@
buf[4] = 0;
- stream.read(buf, 4);
+ stream.read_noThrow(buf, 4);
if (memcmp(buf, "RIFF", 4) != 0) {
warning("getWavInfo: No 'RIFF' header");
return false;
@@ -39,13 +39,13 @@
uint32 wavLength = stream.readUint32LE();
- stream.read(buf, 4);
+ stream.read_noThrow(buf, 4);
if (memcmp(buf, "WAVE", 4) != 0) {
warning("getWavInfo: No 'WAVE' header");
return false;
}
- stream.read(buf, 4);
+ stream.read_noThrow(buf, 4);
if (memcmp(buf, "fmt ", 4) != 0) {
warning("getWavInfo: No 'fmt' header");
return false;
@@ -140,7 +140,7 @@
warning("getWavInfo: Cannot find 'data' chunk");
return false;
}
- stream.read(buf, 4);
+ stream.read_noThrow(buf, 4);
offset = stream.readUint32LE();
#if 0
@@ -170,7 +170,7 @@
byte *data = (byte *)malloc(size);
assert(data);
- stream.read(data, size);
+ stream.read_noThrow(data, size);
// Since we allocated our own buffer for the data, we must set the autofree flag.
flags |= Audio::Mixer::FLAG_AUTOFREE;
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