Use GIO API instead of g_stat() on Windows in compose_add_attachments() and get_file_size().
This commit is contained in:
parent
5407e4537c
commit
211cb04781
2 changed files with 46 additions and 1 deletions
|
@ -2028,6 +2028,27 @@ const gchar *get_domain_name(void)
|
|||
|
||||
off_t get_file_size(const gchar *file)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
GFile *f;
|
||||
GFileInfo *fi;
|
||||
GError *error = NULL;
|
||||
goffset size;
|
||||
|
||||
f = g_file_new_for_path(file);
|
||||
fi = g_file_query_info(f, "standard::size",
|
||||
G_FILE_QUERY_INFO_NONE, NULL, &error);
|
||||
if (error != NULL) {
|
||||
debug_print("get_file_size error: %s\n", error->message);
|
||||
g_error_free(error);
|
||||
g_object_unref(f);
|
||||
return -1;
|
||||
}
|
||||
size = g_file_info_get_size(fi);
|
||||
g_object_unref(fi);
|
||||
g_object_unref(f);
|
||||
return size;
|
||||
|
||||
#else
|
||||
GStatBuf s;
|
||||
|
||||
if (g_stat(file, &s) < 0) {
|
||||
|
@ -2036,6 +2057,7 @@ off_t get_file_size(const gchar *file)
|
|||
}
|
||||
|
||||
return s.st_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
time_t get_file_mtime(const gchar *file)
|
||||
|
|
|
@ -6352,7 +6352,14 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
|
|||
AttachInfo *ainfo;
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist);
|
||||
MimeInfo *mimepart;
|
||||
#ifdef G_OS_WIN32
|
||||
GFile *f;
|
||||
GFileInfo *fi;
|
||||
GError *error = NULL;
|
||||
#else
|
||||
GStatBuf statbuf;
|
||||
#endif
|
||||
goffset size;
|
||||
gchar *type, *subtype;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
@ -6374,15 +6381,31 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
|
|||
}
|
||||
continue;
|
||||
}
|
||||
#ifdef G_OS_WIN32
|
||||
f = g_file_new_for_path(ainfo->file);
|
||||
fi = g_file_query_info(f, "standard::size",
|
||||
G_FILE_QUERY_INFO_NONE, NULL, &error);
|
||||
if (error != NULL) {
|
||||
g_warning(error->message);
|
||||
g_error_free(error);
|
||||
g_object_unref(f);
|
||||
return -1;
|
||||
}
|
||||
size = g_file_info_get_size(fi);
|
||||
g_object_unref(fi);
|
||||
g_object_unref(f);
|
||||
#else
|
||||
if (g_stat(ainfo->file, &statbuf) < 0)
|
||||
return -1;
|
||||
size = statbuf.st_size;
|
||||
#endif
|
||||
|
||||
mimepart = procmime_mimeinfo_new();
|
||||
mimepart->content = MIMECONTENT_FILE;
|
||||
mimepart->data.filename = g_strdup(ainfo->file);
|
||||
mimepart->tmp = FALSE; /* or we destroy our attachment */
|
||||
mimepart->offset = 0;
|
||||
mimepart->length = statbuf.st_size;
|
||||
mimepart->length = size;
|
||||
|
||||
type = g_strdup(ainfo->content_type);
|
||||
|
||||
|
|
Loading…
Reference in a new issue