diff options
Diffstat (limited to 'storage_xml.c')
-rw-r--r-- | storage_xml.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/storage_xml.c b/storage_xml.c index ab7da6e3..8b205c5a 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -30,6 +30,14 @@ #include "md5.h" #include <glib/gstdio.h> +#if GLIB_CHECK_VERSION(2,8,0) +#include <glib/gstdio.h> +#else +/* GLib < 2.8.0 doesn't have g_access, so just use the system access(). */ +#include <unistd.h> +#define g_access access +#endif + typedef enum { XML_PASS_CHECK_ONLY = -1, @@ -243,9 +251,10 @@ GMarkupParser xml_parser = static void xml_init( void ) { - if( ! g_file_test( global.conf->configdir, G_FILE_TEST_EXISTS ) ) + if( g_access( global.conf->configdir, F_OK ) != 0 ) log_message( LOGLVL_WARNING, "The configuration directory `%s' does not exist. Configuration won't be saved.", global.conf->configdir ); - else if( ! g_file_test( global.conf->configdir, G_FILE_TEST_EXISTS ) || g_access( global.conf->configdir, W_OK ) != 0 ) + else if( g_access( global.conf->configdir, F_OK ) != 0 || + g_access( global.conf->configdir, W_OK ) != 0 ) log_message( LOGLVL_WARNING, "Permission problem: Can't read/write from/to `%s'.", global.conf->configdir ); } @@ -372,7 +381,7 @@ static storage_status_t xml_save( irc_t *irc, int overwrite ) g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, path2, ".xml" ); g_free( path2 ); - if( !overwrite && g_file_test( path, G_FILE_TEST_EXISTS ) ) + if( !overwrite && g_access( path, F_OK ) == 0 ) return STORAGE_ALREADY_EXISTS; strcat( path, "~" ); @@ -480,14 +489,18 @@ static gboolean xml_save_nick( gpointer key, gpointer value, gpointer data ) static storage_status_t xml_remove( const char *nick, const char *password ) { - char s[512]; + char s[512], *lc; storage_status_t status; status = xml_check_pass( nick, password ); if( status != STORAGE_OK ) return status; - g_snprintf( s, 511, "%s%s%s", global.conf->configdir, nick, ".xml" ); + lc = g_strdup( nick ); + nick_lc( lc ); + g_snprintf( s, 511, "%s%s%s", global.conf->configdir, lc, ".xml" ); + g_free( lc ); + if( unlink( s ) == -1 ) return STORAGE_OTHER_ERROR; |