From 3abc58ae3606a41f3abd9fa4d9f7638a1fe8a54e Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 20 Jul 2009 22:55:51 +0000 Subject: [PATCH] change loadrom() to use FILE* instead of std::ifstream. sidesteps mbcs path issues --- desmume/src/NDSSystem.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 1c41b8975..6039cdf70 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -739,22 +739,17 @@ static std::vector v; static void loadrom(std::vector* buf, std::string fname) { - std::ifstream fl(fname.c_str()); + FILE* inf = fopen(fname.c_str(),"rb"); + if(!inf) return; - if (!fl.is_open()) - return; - - fl.seekg( 0, std::ios::end ); - int size = fl.tellg(); - - std::filebuf fb; - fb.open (fname.c_str(), std::ios::in | std::ios::binary); - std::istream is(&fb); + fseek(inf,0,SEEK_END); + int size = ftell(inf); + fseek(inf,0,SEEK_SET); gameInfo.resize(size); - is.read(gameInfo.romdata,size); + fread(gameInfo.romdata,1,size,inf); - fb.close(); + fclose(inf); } int NDS_LoadROM(const char *filename, const char *logicalFilename)