From 642baafe9d1742638b9a88d63a47828732f2aeeb Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 6 May 2009 04:13:46 +0000 Subject: [PATCH] win32: rollback filename parsing patch. it can't handle filenames with spaces. i know that was the point, but it doesnt even work with quoted paths. --- desmume/src/windows/DeSmuME_2005.sln | 3 ++ desmume/src/windows/DeSmuME_2005.vcproj | 8 ++- desmume/src/windows/main.cpp | 70 ++----------------------- 3 files changed, 15 insertions(+), 66 deletions(-) diff --git a/desmume/src/windows/DeSmuME_2005.sln b/desmume/src/windows/DeSmuME_2005.sln index c1443642b..a5a94fd92 100644 --- a/desmume/src/windows/DeSmuME_2005.sln +++ b/desmume/src/windows/DeSmuME_2005.sln @@ -17,4 +17,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + AMDCaProjectFile = C:\svn\desmume\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw + EndGlobalSection EndGlobal diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 574f786ce..2ecafe4ae 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -53,7 +53,8 @@ AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig" PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;WIN32;SPU_INTERPOLATE;HAVE_LIBZ;HAVE_LIBZZIP;NOMINMAX;DEBUG;EXPERIMENTAL_WIFI" ExceptionHandling="1" - BufferSecurityCheck="false" + BasicRuntimeChecks="2" + BufferSecurityCheck="true" EnableEnhancedInstructionSet="2" FloatingPointModel="2" WarningLevel="1" @@ -145,6 +146,7 @@ PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI" StringPooling="true" ExceptionHandling="1" + BasicRuntimeChecks="0" StructMemberAlignment="0" BufferSecurityCheck="false" EnableFunctionLevelLinking="false" @@ -680,6 +682,10 @@ RelativePath="..\debug.h" > + + diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 0cf4f96e3..d1ed8fdef 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1855,77 +1855,17 @@ int WINAPI WinMain (HINSTANCE hThisInstance, if (lpszArgument[0] == '\"') sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument); - // Reparse arguments to isolate the ROM filename in the command line - // This should allow for both a filename and a '--xyz' option to be present on the command line. - // If this is not done, loading the ROM fails as all supplied options are considered part of the filename. if (lpszArgument[0]) { - BOOL filename_found = FALSE; - const char *delimiters = " "; - char *context = NULL; - char *arg_token = NULL; - char *dup_arglist = strdup(lpszArgument); - - arg_token = strtok_s(dup_arglist, delimiters, &context); - while ( (filename_found == FALSE) & (arg_token != NULL) ) - { - // A token was found. Its extension will be compared to the known extensions. - // We first must search for a dot, starting from the end of the token. - char *dot_position = NULL; - if ( (dot_position = strrchr(arg_token, '.')) != NULL ) - { - // Look for a known extension - if ( !stricmp(dot_position, ".nds") ) - { - filename_found = TRUE; - } - if ( !stricmp(dot_position, ".gba") ) - { - // The name ends with ".gba", check if it actually ends with ".ds.gba" - if ( strlen(arg_token) > 7 ) - { - if ( !stricmp(dot_position-3, ".ds.gba") ) - { - filename_found = TRUE; - } - } - } - } - if ( filename_found == TRUE ) - { - // Try to open the file in read-only mode - HANDLE test_file_open = CreateFile(arg_token, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if ( test_file_open == INVALID_HANDLE_VALUE ) - { - // Cannot open the file, reset filename_found to continue iterating - filename_found = FALSE; - } - else - { - // The file can be opened and it ends with a plausible extension. - // This is probably the one that should be opened. - CloseHandle(test_file_open); - break; - } - } - // Find the next token in the argument list - arg_token = strtok_s(NULL, delimiters, &context); - } - - if ( filename_found == TRUE ) - { #ifdef EXPERIMENTAL_GBASLOT - if(LoadROM(arg_token)) + if(LoadROM(lpszArgument)) #else - if(LoadROM(arg_token, bad_glob_cflash_disk_image_file)) + if(LoadROM(lpszArgument, bad_glob_cflash_disk_image_file)) #endif - { - romloaded = TRUE; - NDS_UnPause(); - } + { + romloaded = TRUE; + NDS_UnPause(); } - - free(dup_arglist); } MainWindow->Show(SW_NORMAL);