1
0
mirror of https://github.com/simh/simh.git synced 2026-02-01 06:13:34 +00:00

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.
This commit is contained in:
Mark Pizzolato
2022-07-18 04:11:48 -10:00
parent 4ae0de84c6
commit 5c301b0a8c

View File

@@ -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;