From f9fc71473f723f0f37cffe132377bb3c7c7a780e Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Wed, 3 Feb 2021 18:49:20 +0100 Subject: [PATCH] Use Lock() and NativeDosOp to retrieve full path to filenames --- src/host-run.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/host-run.c b/src/host-run.c index ddfef4f..a4e8c7f 100644 --- a/src/host-run.c +++ b/src/host-run.c @@ -3,7 +3,7 @@ #include #include "uae_pragmas.h" -static const char __ver[40] = "$VER: Host-Run v1.4 (2021-02-01)"; +static const char __ver[40] = "$VER: Host-Run v1.5 (2021-02-03)"; int print_usage() { @@ -13,14 +13,11 @@ int print_usage() int main(int argc, char *argv[]) { - char command[255]; - memset(command, '\0', 255); - - if (argc <= 1) - { - printf("Missing argument\n"); - return print_usage(); - } + BPTR lock; + char command[2048]; + char filename[100]; + memset(command, '\0', 2048); + memset(filename, '\0', 100); if (!InitUAEResource()) { @@ -28,17 +25,35 @@ int main(int argc, char *argv[]) return 2; } + if (argc <= 1) + { + printf("Missing argument\n"); + return print_usage(); + } + if (strcmp(argv[1], "?") == 0) { return print_usage(); } + else + { + strcat(command, argv[1]); + strcat(command, " "); + } - for (int i = 1; i < argc; i++) + for (int i = 2; i < argc; i++) { -#ifdef DEBUG - printf("DEBUG: argv[%d]=%s\n", i, argv[i]); -#endif - strcat(command, argv[i]); + if (lock = Lock(argv[i], ACCESS_READ)) + { + NativeDosOp((ULONG)0, (ULONG)lock, (ULONG)filename, (ULONG)100); + UnLock(lock); + strcat(command, filename); + memset(filename, '\0', 100); + } + else + { + strcat(command, argv[i]); + } if (i != argc - 1) strcat(command, " "); @@ -48,5 +63,5 @@ int main(int argc, char *argv[]) printf("DEBUG: argc=%d, command=%s\n", argc, command); #endif ExecuteOnHost((UBYTE *)&command); - memset(command, '\0', 255); + memset(command, '\0', 2048); } \ No newline at end of file