summary refs log tree commit diff stats
path: root/src/common/text.c
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2015-02-28 07:23:11 -0500
committerTingPing <tingping@tingping.se>2015-02-28 07:24:49 -0500
commit749e5b20da486955a54c7be79d9481d465d1d5bd (patch)
treeb2bd6c6de30339ad1ef47dd138264ba58970cc9d /src/common/text.c
parentd78db5070a20c86c56bdb8552da9b242a641f3ee (diff)
Make use of g_path_is_absolute()
No reason to roll our own.. in multiple places
Diffstat (limited to 'src/common/text.c')
-rw-r--r--src/common/text.c40
1 files 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);
 	}