[Scummvm-cvs-logs] SF.net SVN: scummvm:[55214] tools/trunk

jvprat at users.sourceforge.net jvprat at users.sourceforge.net
Wed Jan 12 13:31:18 CET 2011


Revision: 55214
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55214&view=rev
Author:   jvprat
Date:     2011-01-12 12:31:18 +0000 (Wed, 12 Jan 2011)

Log Message:
-----------
TOOLS: Fix the sword2_clue compilation by using Common::File.

Modified Paths:
--------------
    tools/trunk/Makefile.common
    tools/trunk/engines/sword2/sword2_clue.cpp

Modified: tools/trunk/Makefile.common
===================================================================
--- tools/trunk/Makefile.common	2011-01-11 23:16:57 UTC (rev 55213)
+++ tools/trunk/Makefile.common	2011-01-12 12:31:18 UTC (rev 55214)
@@ -173,7 +173,7 @@
 create_sjisfnt.o: CPPFLAGS+=$(FREETYPEINCLUDES) $(ICONVCFLAGS)
 
 
-sword2_clue_OBJS := engines/sword2/sword2_clue.o
+sword2_clue_OBJS := engines/sword2/sword2_clue.o common/file.o
 sword2_clue_LIBS := `pkg-config --libs gtk+-2.0`
 # Set custom build flags
 engines/sword2/sword2_clue.o: CPPFLAGS+=`pkg-config --cflags gtk+-2.0`

Modified: tools/trunk/engines/sword2/sword2_clue.cpp
===================================================================
--- tools/trunk/engines/sword2/sword2_clue.cpp	2011-01-11 23:16:57 UTC (rev 55213)
+++ tools/trunk/engines/sword2/sword2_clue.cpp	2011-01-12 12:31:18 UTC (rev 55214)
@@ -21,6 +21,7 @@
  *
  */
 
+#include "common/file.h"
 #include "common/util.h"
 
 #include <gtk/gtk.h>
@@ -266,7 +267,7 @@
 	uint32 res_sizes[14];
 	int i;
 
-	FILE *in;
+	Common::File in;
 	uint32 index_pos;
 	uint32 pos, len;
 
@@ -277,8 +278,8 @@
 		return EXIT_FAILURE;
 	}
 
-	in = fopen(argv[1], "rb");
-	if (!in) {
+	in.open(argv[1], "rb");
+	if (!in.isOpen()) {
 		printf("Couldn't open %s for reading\n", argv[1]);
 		return EXIT_FAILURE;
 	}
@@ -312,8 +313,8 @@
 	gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), compare_items, NULL, NULL);
 	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
 
-	index_pos = readUint32LE(in);
-	fseek(in, index_pos, SEEK_SET);
+	index_pos = in.readUint32LE();
+	in.seek(index_pos, SEEK_SET);
 
 	for (;;) {
 		GtkTreeIter iter;
@@ -322,23 +323,24 @@
 		gchar name[34];
 		gchar *size;
 
-		pos = readUint32LE(in);
-		len = readUint32LE(in);
-
-		if (pos == EOF || len == EOF)
+		try {
+			pos = in.readUint32LE();
+			len = in.readUint32LE();
+		} catch (...) {
 			break;
+		}
 
 		size = make_size(len);
 
-		index_pos = ftell(in);
+		index_pos = in.pos();
 
-		fseek(in, pos, SEEK_SET);
+		in.seek(pos, SEEK_SET);
 
-		type = readByte(in);
-		readByte(in);				/* compType	*/
-		readUint32LE(in);			/* compSize	*/
-		readUint32LE(in);			/* decompSize	*/
-		fread(name, sizeof(name), 1, in);
+		type = in.readByte();
+		in.readByte();				/* compType	*/
+		in.readUint32LE();			/* compSize	*/
+		in.readUint32LE();			/* decompSize	*/
+		in.read_noThrow(name, sizeof(name));
 
 		/*
 		 * We need to convert from Latin-1 to UTF-8. Otherwise the text
@@ -368,10 +370,10 @@
 			POSITION_COLUMN, pos,
 			LENGTH_COLUMN, len);
 
-		fseek(in, index_pos, SEEK_SET);
+		in.seek(index_pos, SEEK_SET);
 	}
 
-	fclose(in);
+	in.close();
 
 	for (i = 0; i < ARRAYSIZE(res_counts); i++) {
 		if (res_counts[i]) {


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