mirror of
https://github.com/david-schmidt/gsport.git
synced 2024-12-28 03:30:05 +00:00
Make life easier on Windows - drag/drop files get more Posix-like names so you can edit file locations from config window
This commit is contained in:
parent
1c9806253e
commit
e7e481206d
14
src/config.c
14
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;
|
||||
|
@ -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
|
||||
|
@ -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<szFilename;j++) {
|
||||
if (lpszFile[j] == '\\') {
|
||||
lpszFile[j] = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
cfg_inspect_maybe_insert_file(lpszFile);
|
||||
free(lpszFile);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user