From e3b06a96840f824b8a3651069efd55842f562829 Mon Sep 17 00:00:00 2001 From: squall-leonhart Date: Tue, 26 Apr 2011 07:25:16 +0000 Subject: [PATCH] Bugger unicode support, we can just convert multibyte to widestring using google cloud services and a bunch of midgets running in spinwheels. Also enables whole program optimisation (funnily i was only doing linker time optimisation so it wasn't as good as it could be.) git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1013 a31d4220-a93d-0410-bf67-fe4944624d44 --- project/vs2010_mfc/VBA2010.suo | Bin 19968 -> 19968 bytes project/vs2010_mfc/VBA2010.vcxproj | 1 + src/Util.cpp | 47 +++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/project/vs2010_mfc/VBA2010.suo b/project/vs2010_mfc/VBA2010.suo index 17fad8f83225d9a3cbc70d77f81cfda4d19186da..9fa6140abd9d1f1cfdfb2e53ef6244b472b36198 100644 GIT binary patch delta 206 zcmZpe!`Lu~aYGIZdq9vd^L^$slZ#m{Om-GCoW#qrxq`KXiL-`*fuR)lZ#m{Og_wFIEj~Ka|LS&)8rXUBAYl4^Mk}Te-S?~ z%E>6qz`(!+#FOK_6ek<7uy6jNdxmYYosHn+5BAG8mz#EqPv#JC0LrjTKH_ULSwO%7 I$mRjD0c6u9I{*Lx diff --git a/project/vs2010_mfc/VBA2010.vcxproj b/project/vs2010_mfc/VBA2010.vcxproj index 67aab602..8f34f2e6 100644 --- a/project/vs2010_mfc/VBA2010.vcxproj +++ b/project/vs2010_mfc/VBA2010.vcxproj @@ -27,6 +27,7 @@ false NotSet false + true Application diff --git a/src/Util.cpp b/src/Util.cpp index aed4d895..5ca4d0f3 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -435,9 +435,34 @@ static bool utilIsImage(const char *file) return utilIsGBAImage(file) || utilIsGBImage(file); } +#ifdef WIN32 +#include +#endif + IMAGE_TYPE utilFindType(const char *file) { char buffer [2048]; +#ifdef WIN32 + DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, file, -1, NULL, 0); + wchar_t *pwText; + pwText = new wchar_t[dwNum]; + if(!pwText) + { + delete []pwText; + } + MultiByteToWideChar (CP_ACP, 0, file, -1, pwText, dwNum ); + char* file_conv = fex_wide_to_path( pwText); + delete []pwText; + if ( !utilIsImage( file_conv ) ) // TODO: utilIsArchive() instead? + { + fex_t* fe = scan_arc(file_conv,utilIsImage,buffer); + if(!fe) + return IMAGE_UNKNOWN; + fex_close(fe); + file = buffer; + } + free(file_conv); +#else if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead? { fex_t* fe = scan_arc(file,utilIsImage,buffer); @@ -446,7 +471,7 @@ IMAGE_TYPE utilFindType(const char *file) fex_close(fe); file = buffer; } - +#endif return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB; } @@ -465,10 +490,26 @@ u8 *utilLoad(const char *file, { // find image file char buffer [2048]; +#ifdef WIN32 + DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, file, -1, NULL, 0); + wchar_t *pwText; + pwText = new wchar_t[dwNum]; + if(!pwText) + { + delete []pwText; + } + MultiByteToWideChar (CP_ACP, 0, file, -1, pwText, dwNum ); + char* file_conv = fex_wide_to_path( pwText); + delete []pwText; + fex_t *fe = scan_arc(file_conv,accept,buffer); + if(!fe) + return NULL; + free(file_conv); +#else fex_t *fe = scan_arc(file,accept,buffer); if(!fe) return NULL; - +#endif // Allocate space for image fex_err_t err = fex_stat(fe); int fileSize = fex_size(fe); @@ -671,4 +712,4 @@ bool utilFileExists( const char *filename ) fclose( f ); return true; } -} +} \ No newline at end of file