[Scummvm-cvs-logs] CVS: tools rescumm.c,1.9,1.10 util.c,1.2,1.3
Max Horn
fingolfin at users.sourceforge.net
Sun Nov 9 16:09:06 CET 2003
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv28330
Modified Files:
rescumm.c util.c
Log Message:
more cleanup
Index: rescumm.c
===================================================================
RCS file: /cvsroot/scummvm/tools/rescumm.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- rescumm.c 10 Nov 2003 00:02:07 -0000 1.9
+++ rescumm.c 10 Nov 2003 00:08:56 -0000 1.10
@@ -50,34 +50,26 @@
error("Could not open \'%s\'.", data_file_name);
}
- /* get the length of the data file to use for consistency checks */
- if (fseek(ifp, 0, SEEK_END)) {
- fclose(ifp);
- error("Seek error.");
- }
- data_file_len = ftell(ifp);
- if (fseek(ifp, 0, SEEK_SET)) {
- fclose(ifp);
- error("Seek error.");
- }
+ /* Get the length of the data file to use for consistency checks */
+ data_file_len = fileSize(ifp);
- /* read offset and length to the file records */
+ /* Read offset and length to the file records */
file_record_off = readUint32BE(ifp);
file_record_len = readUint32BE(ifp);
- /* do a quick check to make sure the offset and length are good */
+ /* Do a quick check to make sure the offset and length are good */
if (file_record_off + file_record_len > data_file_len) {
fclose(ifp);
error("\'%s\'. file records out of bounds.", data_file_name);
}
- /* do a little consistancy check on file_record_length */
+ /* Do a little consistancy check on file_record_length */
if (file_record_len % 0x28) {
fclose(ifp);
error("\'%s\'. file record length not multiple of 40.", data_file_name);
}
- /* extract the files */
+ /* Extract the files */
for (i = 0; i < file_record_len; i += 0x28) {
/* read a file record */
if (fseek(ifp, file_record_off + i, SEEK_SET)) {
@@ -94,10 +86,10 @@
}
printf("extracting \'%s\'", file_name);
- /* for convience compatability with scummvm (and case sensitive
+ /* For convenience compatibility with scummvm (and case sensitive
* file systems) change the file name to lowercase.
*
- * if i ever add the abbility to pass flags on the command
+ * if i ever add the ability to pass flags on the command
* line, i will make this optional, but i really don't
* see the point to bothering
*/
@@ -115,13 +107,13 @@
}
printf(", saving as \'%s\'\n", file_name);
- /* consistency check. make sure the file data is in the file */
+ /* Consistency check. make sure the file data is in the file */
if (file_off + file_len > data_file_len) {
fclose(ifp);
error("\'%s\'. file out of bounds.", data_file_name);
}
- /* write a file */
+ /* Write a file */
if (fseek(ifp, file_off, SEEK_SET)) {
fclose(ifp);
error("Seek error.");
Index: util.c
===================================================================
RCS file: /cvsroot/scummvm/tools/util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- util.c 9 Nov 2003 23:45:44 -0000 1.2
+++ util.c 10 Nov 2003 00:08:56 -0000 1.3
@@ -76,12 +76,8 @@
}
void readString(uint32 size, char *dest, FILE *fp) {
- uint32 i = 0;
- while (i < size) {
- int c = fgetc(fp);
- dest[i++] = c;
- }
- dest[i] = '\0';
+ fread(dest, 1, size, fp);
+ dest[size+1] = '\0';
}
void writeByte(FILE *fp, uint8 b) {
More information about the Scummvm-git-logs
mailing list