Thu, 17 Apr 2014 08:19:13 +0200
cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)
--- a/libpurple/glibcompat.h Thu Apr 17 06:38:02 2014 +0200 +++ b/libpurple/glibcompat.h Thu Apr 17 08:19:13 2014 +0200 @@ -148,6 +148,18 @@ #endif /* < 2.36.0 */ +/* glib's definition of g_stat+GStatBuf seems to be broken on 32-bit windows, + * so instead of relying on it, we'll define our own macros. + */ +#if defined(_WIN32) && !defined(_MSC_VER) && !defined(_WIN64) +# include <glib/gstdio.h> +typedef struct _stat64 GStatBuf64; +# define GStatBuf GStatBuf64 +# undef g_stat +# define g_stat _stat64 +#endif + + #ifdef __clang__ #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
--- a/libpurple/util.c Thu Apr 17 06:38:02 2014 +0200 +++ b/libpurple/util.c Thu Apr 17 08:19:13 2014 +0200 @@ -3095,12 +3095,17 @@ return FALSE; } /* Use stat to be absolutely sure. */ - if ((g_stat(filename_temp, &st) == -1) || (st.st_size != (off_t)real_size)) - { + if (g_stat(filename_temp, &st) == -1) { purple_debug_error("util", "Error writing data to file %s: " - "Incomplete file written; is your disk " - "full?\n", - filename_temp); + "couldn't g_stat file", filename_temp); + g_free(filename_temp); + return FALSE; + } + if (st.st_size != (off_t)real_size) { + purple_debug_error("util", "Error writing data to file %s: " + "Incomplete file written (%" G_GSIZE_FORMAT " != %" + G_GSIZE_FORMAT "); is your disk full?", + filename_temp, (gsize)st.st_size, real_size); g_free(filename_temp); return FALSE; }