From 5c301b0a8c83dffd034ad07c93754b6c5622af85 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Mon, 18 Jul 2022 04:11:48 -1000 Subject: [PATCH] SCP: Retain full path for open log files There are cases where a log might be closed and reopened which might be problematic if the current working directory had changed. --- sim_console.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sim_console.c b/sim_console.c index 6bf5a7a5..7b6f5a71 100644 --- a/sim_console.c +++ b/sim_console.c @@ -2722,15 +2722,18 @@ else if (strcmp (gbuf, "STDERR") == 0) { /* output to stderr? */ *pref = NULL; } else { + char *fullpath = NULL; + *pref = (FILEREF *)calloc (1, sizeof(**pref)); if (!*pref) return SCPE_MEM; - get_glyph_nc (filename, gbuf, 0); /* reparse */ - strlcpy ((*pref)->name, gbuf, sizeof((*pref)->name)); + fullpath = sim_filepath_parts (filename, "f"); /* reparse */ + strlcpy ((*pref)->name, fullpath, sizeof((*pref)->name)); if (sim_switches & SWMASK ('N')) /* if a new log file is requested */ - *pf = sim_fopen (gbuf, (binary ? "w+b" : "w+"));/* then open an empty file */ + *pf = sim_fopen (fullpath, (binary ? "w+b" : "w+"));/* then open an empty file */ else /* otherwise */ - *pf = sim_fopen (gbuf, (binary ? "a+b" : "a+"));/* append to an existing file */ + *pf = sim_fopen (fullpath, (binary ? "a+b" : "a+"));/* append to an existing file */ + free (fullpath); if (*pf == NULL) { /* error? */ free (*pref); *pref = NULL;