From 6cf907f303c414a5fed994e7c74a3004eace7cdc Mon Sep 17 00:00:00 2001 From: Andrea Date: Tue, 29 Dec 2020 21:13:35 +0000 Subject: [PATCH] In Linux, save logfile to /tmp. (PR #900) --- source/Log.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/Log.cpp b/source/Log.cpp index a1137aa3..1a0124f6 100644 --- a/source/Log.cpp +++ b/source/Log.cpp @@ -31,6 +31,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Log.h" FILE* g_fh = NULL; +#ifdef _MSC_VER +#define LOG_FILENAME "AppleWin.log" +#else +// save to /tmp as otherwise it creates a file in the current folder which can be a bit everywhere +// especially if the program is installed to /usr +#define LOG_FILENAME "/tmp/AppleWin.log" +#endif + + //--------------------------------------------------------------------------- void LogInit(void) @@ -38,7 +47,7 @@ void LogInit(void) if (g_fh) return; - g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text mode) + g_fh = fopen(LOG_FILENAME, "a+t"); // Open log file (append & text mode) setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf) CHAR aDateStr[80], aTimeStr[80]; GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));