diff options
author | Tony Puccinelli | 2010-07-13 03:24:06 +0000 |
---|---|---|
committer | Tony Puccinelli | 2010-07-13 03:24:06 +0000 |
commit | 9d06726b6904f57ca62f3ff89e8c609acbe13ee2 (patch) | |
tree | 3b880279a8946a32c3cff40a0a00fc84d5154132 /backends | |
parent | eced5b3c82c93d9febb14b5fe4eba34d5ce171b8 (diff) | |
download | scummvm-rg350-9d06726b6904f57ca62f3ff89e8c609acbe13ee2.tar.gz scummvm-rg350-9d06726b6904f57ca62f3ff89e8c609acbe13ee2.tar.bz2 scummvm-rg350-9d06726b6904f57ca62f3ff89e8c609acbe13ee2.zip |
Started changing loader to use Common::SeekableReadStream
svn-id: r50839
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/ds/arm9/source/dsloader.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/backends/platform/ds/arm9/source/dsloader.cpp b/backends/platform/ds/arm9/source/dsloader.cpp index 543d3648b5..ad5160a5b2 100644 --- a/backends/platform/ds/arm9/source/dsloader.cpp +++ b/backends/platform/ds/arm9/source/dsloader.cpp @@ -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 @@ bool DLObject::load(int fd) { 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::load(int fd) { 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 @@ bool DLObject::open(const char *path) { (**f)(); DBG(("%s opened ok.\n", path)); + return false; return true; } |