mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-21 16:55:02 -05:00
Make use of g_path_is_absolute()
No reason to roll our own.. in multiple places
This commit is contained in:
parent
d78db5070a
commit
749e5b20da
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user