talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit b97b0cead96edc843ddb0f9a9b8dd3ed03319271
parent 211cb0478112f813743d1a43266f1eef946c6bd2
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun, 29 Oct 2017 18:40:54 +0100

Use GIO API instead of g_stat() in compose_draft() on Windows.

Diffstat:
Msrc/compose.c | 34++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/compose.c b/src/compose.c @@ -10483,26 +10483,56 @@ warn_err: compose_close(compose); return TRUE; } else { +#ifdef G_OS_WIN32 + GFile *f; + GFileInfo *fi; + GTimeVal tv; + GError *error; +#else GStatBuf s; +#endif gchar *path; + goffset size, mtime; path = folder_item_fetch_msg(draft, msgnum); if (path == NULL) { debug_print("can't fetch %s:%d\n", draft->path, msgnum); goto unlock; } +#ifdef G_OS_WIN32 + f = g_file_new_for_path(path); + fi = g_file_query_info(f, "standard::size,time::modified", + G_FILE_QUERY_INFO_NONE, NULL, &error); + if (error != NULL) { + debug_print("couldn't query file info for '%s': %s\n", + path, error->message); + g_error_free(error); + g_free(path); + g_object_unref(f); + goto unlock; + } + size = g_file_info_get_size(fi); + g_file_info_get_modification_time(fi, &tv); + mtime = tv.tv_sec; + g_object_unref(fi); + g_object_unref(f); + g_free(path); +#else if (g_stat(path, &s) < 0) { FILE_OP_ERROR(path, "stat"); g_free(path); goto unlock; } + size = s.st_size; + mtime = s.st_mtime; +#endif g_free(path); procmsg_msginfo_free(&(compose->targetinfo)); compose->targetinfo = procmsg_msginfo_new(); compose->targetinfo->msgnum = msgnum; - compose->targetinfo->size = (goffset)s.st_size; - compose->targetinfo->mtime = s.st_mtime; + compose->targetinfo->size = size; + compose->targetinfo->mtime = mtime; compose->targetinfo->folder = draft; if (target_locked) procmsg_msginfo_set_flags(compose->targetinfo, MSG_LOCKED, 0);