diff --git a/src/config.c b/src/config.c index 6e69691..7a27f27 100644 --- a/src/config.c +++ b/src/config.c @@ -1294,7 +1294,19 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size, name_len = strlen(name); name_ptr = (char *)malloc(name_len + 1); +#if defined(_WIN32) || defined(__CYGWIN__) + // On Windows, we need to change backslashes to forward slashes. + for (i = 0; i < name_len; i++) { + if (name[i] == '\\') { + name_ptr[i] = '/'; + } else { + name_ptr[i] = name[i]; + } + } + name_ptr[name_len] = 0; +#else strncpy(name_ptr, name, name_len + 1); +#endif dsk->name_ptr = name_ptr; dsk->partition_name = 0; @@ -1358,7 +1370,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size, } if((!dsk->file) && can_write) { - printf("Trying to open %s read-only, errno: %d\n", name_ptr, +rrrrr printf("Trying to open %s read-only, errno: %d\n", name_ptr, errno); dsk->file = fopen(name_ptr, "rb"); can_write = 0; diff --git a/src/sim65816.c b/src/sim65816.c index ea9cbb1..e18e87d 100644 --- a/src/sim65816.c +++ b/src/sim65816.c @@ -1057,20 +1057,7 @@ gsportmain(int argc, char **argv) config_init(); // If the final argument was not a switch, then treat it like a disk image filename to insert if (final_arg) { -#if defined(_WIN32) || defined(__CYGWIN__) - // On Windows, we need to change backslashes to forward slashes. - filename_ptr = malloc(strlen(final_arg +1)); - strcpy(filename_ptr,final_arg); - for (i = 0; i < strlen(filename_ptr);i++) { - if (filename_ptr[i] == '\\') filename_ptr[i] = '/'; - } -#else - filename_ptr = final_arg; -#endif - cfg_inspect_maybe_insert_file(filename_ptr); -f#if defined(_WIN32) || defined(__CYGWIN__) - free(filename_ptr); -#endif + cfg_inspect_maybe_insert_file(final_arg); } printer_init(g_printer_dpi,85,110,g_printer_output,g_printer_multipage); //If ethernet is enabled in config.gsport, let's initialize it diff --git a/src/win_generic.c b/src/win_generic.c index 6f394b8..61dda5d 100644 --- a/src/win_generic.c +++ b/src/win_generic.c @@ -473,14 +473,6 @@ LPTSTR lpszFile; szFilename = DragQueryFile((HDROP)wParam, i, NULL, 0); lpszFile = (LPTSTR)malloc(szFilename + 1); szFilename = DragQueryFile((HDROP)wParam, i, lpszFile, szFilename + 1); - // Need to swap out backslashes, swap in forward slashes - if (szFilename > 0) { - for (j = 0;j