diff options
Diffstat (limited to 'src/common/text.c')
-rw-r--r-- | src/common/text.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/common/text.c b/src/common/text.c index 220fca1b..e12021c9 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -595,15 +595,25 @@ log_create_pathname (char *servname, char *channame, char *netname) tm = localtime (&now); strftime (fnametime, sizeof (fnametime), fname, tm); - /* create final path/filename */ + /* create final path/filename, check if it's absolute or relative */ #ifdef WIN32 - if (fnametime[0] == '/' || (fnametime[0] >= 'A' && fnametime[1] == ':')) + if ((fnametime[0] >= 'A' && fnametime[0] <= 'Z') || (fnametime[0] >= 'a' && fnametime[0] <= 'z') && fnametime[1] == ':') #else - if (fnametime[0] == '/') /* is it fullpath already? */ + /* If one uses log mask variables, such as "%c/...", %c will be empty upon + * connecting since there's no channel name yet, so we have to make sure + * we won't try to write to the FS root. On Windows we can be sure it's + * full path if the 2nd character is a colon since Windows doesn't allow + * colons in filenames. + */ + if (fnametime[0] == '/' && prefs.logmask[0] != '%') #endif + { snprintf (fname, sizeof (fname), "%s", fnametime); - else + } + else /* relative path */ + { snprintf (fname, sizeof (fname), "%s/logs/%s", get_xdir_utf8 (), fnametime); + } /* now we need it in FileSystem encoding */ fs = xchat_filename_from_utf8 (fname, -1, 0, 0, 0); |