Mercurial > pidgin
diff libpurple/core.c @ 19114:6de2e9ba0930
merge of '2970edca111b3535ae0703e3c866ad1c3b87df94'
and 'a2b508e8680ac3f20965226a5dd83f7e2a3b15bb'
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Sun, 24 Jun 2007 02:56:09 +0000 |
parents | 4cc042912ac2 |
children | 73ea3328b0d1 |
line wrap: on
line diff
--- a/libpurple/core.c Sun Jun 24 02:55:54 2007 +0000 +++ b/libpurple/core.c Sun Jun 24 02:56:09 2007 +0000 @@ -489,13 +489,33 @@ /* We're only going to duplicate a logs symlink. */ if (!strcmp(entry, "logs")) { + char *link; +#if GLIB_CHECK_VERSION(2,4,0) + GError *err = NULL; + + if ((link = g_file_read_link(name, &err)) == NULL) + { + char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); + purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\n", + name_utf8 ? name_utf8 : name, err->message); + g_free(name_utf8); + g_error_free(err); + g_free(name); + g_dir_close(dir); + g_free(status_file); + g_free(old_user_dir); + return FALSE; + } +#else char buf[MAXPATHLEN]; size_t linklen; if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) { + char *name_utf8 = g_filename_to_utf8(name, -1, NULL, NULL, NULL); purple_debug_error("core", "Error reading symlink %s: %s. Please report this at http://developer.pidgin.im\n", - name, strerror(errno)); + name_utf8, strerror(errno)); + g_free(name_utf8); g_free(name); g_dir_close(dir); g_free(status_file); @@ -504,13 +524,18 @@ } buf[linklen] = '\0'; - logs_dir = g_strconcat(user_dir, G_DIR_SEPARATOR_S "logs", NULL); + /* This way we don't have to GLIB_VERSION_CHECK every g_free(link) below. */ + link = g_strdup(buf); +#endif - if (!strcmp(buf, "../.purple/logs") || !strcmp(buf, logs_dir)) + logs_dir = g_build_filename(user_dir, "logs", NULL); + + if (!strcmp(link, "../.purple/logs") || !strcmp(link, logs_dir)) { /* If the symlink points to the new directory, we're * likely just trying again after a failed migration, * so there's no need to fail here. */ + g_free(link); g_free(logs_dir); continue; } @@ -522,12 +547,13 @@ g_unlink(logs_dir); /* Relative links will most likely still be - * valid from ~/.purple, though not it's not + * valid from ~/.purple, though it's not * guaranteed. Oh well. */ - if (symlink(buf, logs_dir)) + if (symlink(link, logs_dir)) { purple_debug_error("core", "Error symlinking %s to %s: %s. Please report this at http://developer.pidgin.im\n", - logs_dir, buf, strerror(errno)); + logs_dir, link, strerror(errno)); + g_free(link); g_free(name); g_free(logs_dir); g_dir_close(dir); @@ -536,6 +562,7 @@ return FALSE; } + g_free(link); g_free(logs_dir); continue; }