From 6a2543444cf596023efd4d8f185088ecdbc0d507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Mon, 4 Aug 2014 12:39:08 +0000 Subject: [PATCH] W32: use 64-bit stat for localfile size calculation https://bugzilla.gnome.org/show_bug.cgi?id=728669 --- gio/glocalfile.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/gio/glocalfile.c b/gio/glocalfile.c index eed3a99e3..327fe6fda 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -2660,10 +2660,38 @@ g_local_file_measure_size_of_file (gint parent_fd, #if defined (AT_FDCWD) if (fstatat (parent_fd, name->data, &buf, AT_SYMLINK_NOFOLLOW) != 0) -#else - if (g_lstat (name->data, &buf) != 0) -#endif return g_local_file_measure_size_error (state->flags, errno, name, error); +#elif defined (HAVE_LSTAT) || !defined (G_OS_WIN32) + if (g_lstat (name->data, &buf) != 0) + return g_local_file_measure_size_error (state->flags, errno, name, error); +#else + { + const char *filename = (const gchar *) name->data; + wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); + int retval; + int save_errno; + int len; + + if (wfilename == NULL) + return g_local_file_measure_size_error (state->flags, errno, name, error); + + len = wcslen (wfilename); + while (len > 0 && G_IS_DIR_SEPARATOR (wfilename[len-1])) + len--; + if (len > 0 && + (!g_path_is_absolute (filename) || len > g_path_skip_root (filename) - filename)) + wfilename[len] = '\0'; + + retval = _wstat32i64 (wfilename, &buf); + save_errno = errno; + + g_free (wfilename); + + errno = save_errno; + if (retval != 0) + return g_local_file_measure_size_error (state->flags, errno, name, error); + } +#endif if (name->next) {