[Scummvm-cvs-logs] SF.net SVN: scummvm: [25661] scummvm/trunk/engines/agos/debug.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Feb 17 21:37:57 CET 2007


Revision: 25661
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25661&view=rev
Author:   fingolfin
Date:     2007-02-17 12:37:57 -0800 (Sat, 17 Feb 2007)

Log Message:
-----------
Using stat and fopen is not portable (writing to a Common::File isn't either, but at least it doesn't force porters to #define fopen to work around it)

Modified Paths:
--------------
    scummvm/trunk/engines/agos/debug.cpp

Modified: scummvm/trunk/engines/agos/debug.cpp
===================================================================
--- scummvm/trunk/engines/agos/debug.cpp	2007-02-17 18:55:51 UTC (rev 25660)
+++ scummvm/trunk/engines/agos/debug.cpp	2007-02-17 20:37:57 UTC (rev 25661)
@@ -29,8 +29,6 @@
 #include "agos/intern.h"
 #include "agos/vga.h"
 
-#include <sys/stat.h>
-
 namespace AGOS {
 
 const byte *AGOSEngine::dumpOpcode(const byte *p) {
@@ -393,14 +391,13 @@
 };
 
 void dumpBMP(const char *filename, int w, int h, const byte *bytes, const uint32 *palette) {
-	FILE *out = fopen(filename, "wb");
+	Common::File out;
 	byte my_hdr[sizeof(bmp_hdr)];
 	int i;
 
-	if (out == NULL) {
-		printf("DUMP ERROR\n");
+	out.open(filename, Common::File::kFileWriteMode);
+	if (!out.isOpen())
 		return;
-	}
 
 	memcpy(my_hdr, bmp_hdr, sizeof(bmp_hdr));
 
@@ -409,7 +406,7 @@
 	*(uint32 *)(my_hdr + 22) = h;
 
 
-	fwrite(my_hdr, 1, sizeof(my_hdr), out);
+	out.write(my_hdr, sizeof(my_hdr));
 
 	for (i = 0; i != 256; i++, palette++) {
 		byte color[4];
@@ -417,14 +414,12 @@
 		color[1] = (byte)(*palette >> 8);
 		color[2] = (byte)(*palette);
 		color[3] = 0;
-		fwrite(color, 1, 4, out);
+		out.write(color, 4);
 	}
 
 	while (--h >= 0) {
-		fwrite(bytes + h * ((w + 3) & ~3), ((w + 3) & ~3), 1, out);
+		out.write(bytes + h * ((w + 3) & ~3), ((w + 3) & ~3));
 	}
-
-	fclose(out);
 }
 
 void AGOSEngine::dumpBitmap(const char *filename, const byte *offs, int w, int h, int flags, const byte *palette,
@@ -468,20 +463,11 @@
 
 void AGOSEngine::dumpSingleBitmap(int file, int image, const byte *offs, int w, int h, byte base) {
 	char buf[40];
-#if !defined(PALMOS_MODE) && !defined(__DC__) && !defined(__PSP__) && !defined(__PLAYSTATION2__)
-	struct stat statbuf;
-#endif
 
-#if defined(MACOS_CARBON)
-	sprintf(buf, ":dumps:File%d_Image%d.bmp", file, image);
-#else
 	sprintf(buf, "dumps/File%d_Image%d.bmp", file, image);
-#endif
 
-#if !defined(PALMOS_MODE) && !defined(__DC__) && !defined(__PSP__) && !defined(__PLAYSTATION2__)
-	if (stat(buf, &statbuf) == 0)
+	if (Common::File::exists(buf))
 		return;
-#endif
 
 	dumpBitmap(buf, offs, w, h, 0, _displayPalette, base);
 }
@@ -542,11 +528,7 @@
 
 		/* dump bitmap */
 		char buf[40];
-#if defined(MACOS_CARBON)
-		sprintf(buf, ":dumps:Res%d_Image%d.bmp", res, i);
-#else
 		sprintf(buf, "dumps/Res%d_Image%d.bmp", res, i);
-#endif
 
 		dumpBitmap(buf, vga + offs, width, height, flags, pal, 0);
 	}


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