[Scummvm-cvs-logs] SF.net SVN: scummvm:[50839] scummvm/branches/gsoc2010-plugins/backends/ platform/ds/arm9/source/dsloader.cpp

toneman1138 at users.sourceforge.net toneman1138 at users.sourceforge.net
Tue Jul 13 05:24:06 CEST 2010


Revision: 50839
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50839&view=rev
Author:   toneman1138
Date:     2010-07-13 03:24:06 +0000 (Tue, 13 Jul 2010)

Log Message:
-----------
Started changing loader to use Common::SeekableReadStream

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/source/dsloader.cpp

Modified: scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/source/dsloader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/source/dsloader.cpp	2010-07-13 03:22:42 UTC (rev 50838)
+++ scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/source/dsloader.cpp	2010-07-13 03:24:06 UTC (rev 50839)
@@ -31,19 +31,26 @@
 #include <stdio.h>
 #include <malloc.h>
 #include <unistd.h>
-#include <sys/fcntl.h>
+#include <sys/_default_fcntl.h>
 
+#include "common/str.h"
+#include "common/util.h"
+#include "backends/fs/stdiostream.h"
+#include "backends/fs/ds/ds-fs.h"
+#include "dsmain.h"
+#include "fat/gba_nds_fat.h"
+
 #include "backends/platform/ds/arm9/source/dsloader.h"
 
 #define __DS_DEBUG_PLUGINS__
 
 #ifdef __DS_DEBUG_PLUGINS__
-#define DBG(x,...) printf(x, ## __VA_ARGS__)
+#define DBG(x,...) consolePrintf(x, ## __VA_ARGS__)
 #else
 #define DBG(x,...)
 #endif
 
-#define seterror(x,...) fprintf(stderr,x, ## __VA_ARGS__)
+#define seterror(x,...) consolePrintf(x, ## __VA_ARGS__)
 
 // Expel the symbol table from memory
 void DLObject::discard_symtab() {
@@ -333,7 +340,7 @@
 
 	for (int i = 0; i < ehdr.e_phnum; i++) {	//	Load our 2 segments
 
-		fprintf(stderr, "Loading segment %d\n", i);
+		DBG("Loading segment %d\n", i);
 
 		if (readProgramHeaders(fd, &ehdr, &phdr, i) == false)
 			return false;
@@ -365,16 +372,22 @@
 
 bool DLObject::open(const char *path) {
 	int fd;
+
+	Common::SeekableReadStream* DLFile; //TODO: reimplement everything with SeekableReadStream instead of fd
 	void *ctors_start, *ctors_end;
 
-	DBG(("open(\"%s\")\n", path));
+	DBG("open(\"%s\")\n", path);
 
-	if ((fd = ::open(path, O_RDONLY)) < 0) {
+	Common::FSNode file(path);
+
+	if (!(DLFile = file.createReadStream())) {
 		seterror("%s not found.", path);
 		return false;
 	}
 
-	// Try to load and relocate
+	DBG("%s found!\n", path);
+
+	/*Try to load and relocate*/
 	if (!load(fd)) {
 		::close(fd);
 		unload();
@@ -403,6 +416,7 @@
 		(**f)();
 
 	DBG(("%s opened ok.\n", path));
+	return false;
 	return true;
 }
 


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