From 749e5b20da486955a54c7be79d9481d465d1d5bd Mon Sep 17 00:00:00 2001 From: TingPing Date: Sat, 28 Feb 2015 07:23:11 -0500 Subject: Make use of g_path_is_absolute() No reason to roll our own.. in multiple places --- src/common/text.c | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/common/text.c b/src/common/text.c index e8243833..00bc3729 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -501,34 +501,6 @@ log_insert_vars (char *buf, int bufsize, char *fmt, char *c, char *n, char *s) } } -static int -logmask_is_fullpath () -{ - /* Check if final path/filename is absolute or relative. - * 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. - */ -#ifdef WIN32 - /* Treat it as full path if it - * - starts with '\' which denotes the root directory of the current drive letter - * - starts with a drive letter and followed by ':' - */ - if (prefs.hex_irc_logmask[0] == '\\' || (((prefs.hex_irc_logmask[0] >= 'A' && prefs.hex_irc_logmask[0] <= 'Z') || (prefs.hex_irc_logmask[0] >= 'a' && prefs.hex_irc_logmask[0] <= 'z')) && prefs.hex_irc_logmask[1] == ':')) -#else - if (prefs.hex_irc_logmask[0] == '/') -#endif - { - return 1; - } - else - { - return 0; - } -} - static char * log_create_pathname (char *servname, char *channame, char *netname) { @@ -563,8 +535,10 @@ log_create_pathname (char *servname, char *channame, char *netname) now = time (NULL); strftime_utf8 (fnametime, sizeof (fnametime), fname, now); - /* create final path/filename */ - if (logmask_is_fullpath ()) + /* 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. */ + if (g_path_is_absolute (prefs.hex_irc_logmask)) { g_snprintf (fname, sizeof (fname), "%s", fnametime); } @@ -2186,12 +2160,8 @@ sound_play (const char *file, gboolean quiet) return; } -#ifdef WIN32 /* check for fullpath */ - if (file[0] == '\\' || (((file[0] >= 'A' && file[0] <= 'Z') || (file[0] >= 'a' && file[0] <= 'z')) && file[1] == ':')) -#else - if (file[0] == '/') -#endif + if (g_path_is_absolute (file)) { wavfile = g_strdup (file); } -- cgit 1.4.1