From: Andrej Kacian Date: Fri, 5 Jun 2015 11:33:32 +0000 (+0200) Subject: Use 'GStatBuf' instead of 'struct stat' type where possible. X-Git-Tag: 3.12.0~128 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=f061b67c93c7b39a5d9490a320bcbaaed105bc94 Use 'GStatBuf' instead of 'struct stat' type where possible. --- diff --git a/src/addrbook.c b/src/addrbook.c index 04e6c8c6c..ec6a723f4 100644 --- a/src/addrbook.c +++ b/src/addrbook.c @@ -1790,7 +1790,7 @@ GList *addrbook_get_bookfile_list(AddressBookFile *book) { gchar *adbookdir; GDir *dir; const gchar *dir_name; - struct stat statbuf; + GStatBuf statbuf; gchar buf[WORK_BUFLEN + 1]; gchar numbuf[WORK_BUFLEN]; gint len, lenpre, lensuf, lennum; diff --git a/src/addrcache.c b/src/addrcache.c index eb99af15a..2765b41bb 100644 --- a/src/addrcache.c +++ b/src/addrcache.c @@ -242,7 +242,7 @@ void addrcache_free( AddressCache *cache ) { */ gboolean addrcache_check_file( AddressCache *cache, gchar *path ) { gboolean retVal; - struct stat filestat; + GStatBuf filestat; retVal = TRUE; if( path ) { if( 0 == g_stat( path, &filestat ) ) { @@ -258,7 +258,7 @@ gboolean addrcache_check_file( AddressCache *cache, gchar *path ) { */ gboolean addrcache_mark_file( AddressCache *cache, gchar *path ) { gboolean retVal = FALSE; - struct stat filestat; + GStatBuf filestat; if( path ) { if( 0 == g_stat( path, &filestat ) ) { cache->modifyTime = filestat.st_mtime; diff --git a/src/addrharvest.c b/src/addrharvest.c index d862eca36..999dcda7a 100644 --- a/src/addrharvest.c +++ b/src/addrharvest.c @@ -765,7 +765,7 @@ static void addrharvest_harvest_dir( { DIR *dp; struct dirent *d; - struct stat s; + GStatBuf s; gint num; int r; diff --git a/src/common/template.c b/src/common/template.c index 683f26362..bac5c7f6c 100644 --- a/src/common/template.c +++ b/src/common/template.c @@ -158,7 +158,7 @@ GSList *template_read_config(void) gchar *filename; GDir *dir; const gchar *dir_name; - struct stat s; + GStatBuf s; Template *tmpl; GSList *tmpl_list = NULL; diff --git a/src/common/utils.c b/src/common/utils.c index 064d12a95..a135a9952 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2135,7 +2135,7 @@ const gchar *get_domain_name(void) off_t get_file_size(const gchar *file) { - struct stat s; + GStatBuf s; if (g_stat(file, &s) < 0) { FILE_OP_ERROR(file, "stat"); @@ -2147,7 +2147,7 @@ off_t get_file_size(const gchar *file) time_t get_file_mtime(const gchar *file) { - struct stat s; + GStatBuf s; if (g_stat(file, &s) < 0) { FILE_OP_ERROR(file, "stat"); @@ -2185,7 +2185,7 @@ off_t get_file_size_as_crlf(const gchar *file) gboolean file_exist(const gchar *file, gboolean allow_fifo) { - struct stat s; + GStatBuf s; if (file == NULL) return FALSE; @@ -2493,7 +2493,7 @@ gint remove_all_numbered_files(const gchar *dir) gint remove_dir_recursive(const gchar *dir) { - struct stat s; + GStatBuf s; GDir *dp; const gchar *dir_name; gchar *prev_dir; @@ -3242,7 +3242,7 @@ static gchar *file_read_to_str_full(const gchar *file, gboolean recode) { FILE *fp; gchar *str; - struct stat s; + GStatBuf s; #ifndef G_OS_WIN32 gint fd, err; struct timeval timeout = {1, 0}; @@ -5335,7 +5335,7 @@ gboolean prefs_common_get_use_shred(void); int claws_unlink(const gchar *filename) { - struct stat s; + GStatBuf s; static int found_shred = -1; static const gchar *args[4]; @@ -5426,7 +5426,7 @@ static GSList *cm_split_path(const gchar *filename, int depth) { gchar **path_parts; GSList *canonical_parts = NULL; - struct stat st; + GStatBuf st; int i; gboolean follow_symlinks = TRUE; diff --git a/src/common/w32_stat.c b/src/common/w32_stat.c index 087527440..8abbec7cf 100644 --- a/src/common/w32_stat.c +++ b/src/common/w32_stat.c @@ -24,7 +24,7 @@ #include "w32lib.h" -int lstat( const char *file_name, struct stat *buf ){ - return stat( file_name, buf ); +int lstat( const char *file_name, GStatBuf *buf ){ + return g_stat( file_name, buf ); } diff --git a/src/common/w32lib.h b/src/common/w32lib.h index 135883294..69e68dd88 100644 --- a/src/common/w32lib.h +++ b/src/common/w32lib.h @@ -174,7 +174,7 @@ struct timezone { #endif /*** stat ***/ -int lstat( const char *file_name, struct stat *buf ); +int lstat( const char *file_name, GStatBuf *buf ); /*** sys/wait ***/ pid_t waitpid( pid_t pid, int *status, int options ); diff --git a/src/compose.c b/src/compose.c index 926a033a4..2cf8df888 100644 --- a/src/compose.c +++ b/src/compose.c @@ -3576,7 +3576,7 @@ static ComposeInsertResult compose_insert_file(Compose *compose, const gchar *fi gint len; FILE *fp; gboolean prev_autowrap; - struct stat file_stat; + GStatBuf file_stat; int ret; GString *file_contents = NULL; ComposeInsertResult result = COMPOSE_INSERT_SUCCESS; @@ -6126,7 +6126,7 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent) AttachInfo *ainfo; GtkTreeView *tree_view = GTK_TREE_VIEW(compose->attach_clist); MimeInfo *mimepart; - struct stat statbuf; + GStatBuf statbuf; gchar *type, *subtype; GtkTreeModel *model; GtkTreeIter iter; diff --git a/src/jpilot.c b/src/jpilot.c index a0ca9f335..fde63ce37 100644 --- a/src/jpilot.c +++ b/src/jpilot.c @@ -353,7 +353,7 @@ static gchar *jpilot_get_pc3_file( JPilotFile *pilotFile ) { */ static gboolean jpilot_mark_files( JPilotFile *pilotFile ) { gboolean retVal = FALSE; - struct stat filestat; + GStatBuf filestat; gchar *pcFile; /* Mark PDB file cache */ @@ -381,7 +381,7 @@ static gboolean jpilot_mark_files( JPilotFile *pilotFile ) { */ static gboolean jpilot_check_files( JPilotFile *pilotFile ) { gboolean retVal = TRUE; - struct stat filestat; + GStatBuf filestat; gchar *pcFile; /* Check main file */ diff --git a/src/mh.c b/src/mh.c index b3fbc9c3f..d1f4410ba 100644 --- a/src/mh.c +++ b/src/mh.c @@ -212,7 +212,7 @@ static void mh_folder_init(Folder *folder, const gchar *name, const gchar *path) gboolean mh_scan_required(Folder *folder, FolderItem *item) { gchar *path; - struct stat s; + GStatBuf s; path = folder_item_get_path(item); cm_return_val_if_fail(path != NULL, FALSE); @@ -727,7 +727,7 @@ static gint mh_remove_all_msg(Folder *folder, FolderItem *item) static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo) { - struct stat s; + GStatBuf s; if (g_stat(itos(msginfo->msgnum), &s) < 0 || msginfo->size != s.st_size || ( @@ -1103,7 +1103,7 @@ static void mh_scan_tree_recursive(FolderItem *item) struct dirent *d; #endif const gchar *dir_name; - struct stat s; + GStatBuf s; gchar *real_path, *entry, *utf8entry, *utf8name; gint n_msg = 0; @@ -1427,7 +1427,7 @@ static int mh_item_close(Folder *folder, FolderItem *item) static void mh_set_mtime(Folder *folder, FolderItem *item) { - struct stat s; + GStatBuf s; gchar *path = folder_item_get_path(item); cm_return_if_fail(path != NULL); diff --git a/src/plugins/archive/archiver_gtk.c b/src/plugins/archive/archiver_gtk.c index 0bba669a7..447de796d 100644 --- a/src/plugins/archive/archiver_gtk.c +++ b/src/plugins/archive/archiver_gtk.c @@ -657,7 +657,7 @@ static void show_result(struct ArchivePage* page) { N_COLUMNS }; - struct stat st; + GStatBuf st; GtkListStore* list; GtkTreeIter iter; GtkTreeView* view; diff --git a/src/plugins/archive/libarchive_archive.c b/src/plugins/archive/libarchive_archive.c index 1da945004..a0536d42d 100644 --- a/src/plugins/archive/libarchive_archive.c +++ b/src/plugins/archive/libarchive_archive.c @@ -630,7 +630,7 @@ const gchar* archive_create(const char* archive_name, GSList* files, #ifdef _TEST void archive_scan_folder(const char* dir) { - struct stat st; + GStatBuf st; DIR* root; struct dirent* ent; gchar cwd[PATH_MAX]; diff --git a/src/plugins/clamd/clamav_plugin.c b/src/plugins/clamd/clamav_plugin.c index 4194869a9..c363e959b 100644 --- a/src/plugins/clamd/clamav_plugin.c +++ b/src/plugins/clamd/clamav_plugin.c @@ -85,7 +85,7 @@ static gboolean scan_func(GNode *node, gpointer data) gchar *outfile; response buf; int max; - struct stat info; + GStatBuf info; gchar* msg; outfile = procmime_get_tmp_file_name(mimeinfo); @@ -93,7 +93,7 @@ static gboolean scan_func(GNode *node, gpointer data) g_warning("Can't get the part of multipart message."); else { max = config.clamav_max_size * 1048576; /* maximum file size */ - if (stat(outfile, &info) == -1) + if (g_stat(outfile, &info) == -1) g_warning("Can't determine file size"); else { if (info.st_size <= max) { diff --git a/src/plugins/clamd/clamav_plugin_gtk.c b/src/plugins/clamd/clamav_plugin_gtk.c index f400f6d86..c2b29f56d 100644 --- a/src/plugins/clamd/clamav_plugin_gtk.c +++ b/src/plugins/clamd/clamav_plugin_gtk.c @@ -104,7 +104,7 @@ static void clamd_folder_cb(GtkWidget *widget, gpointer data) } static void check_permission(gchar* folder) { - struct stat info; + GStatBuf info; if (g_stat(folder, &info) < 0) return; diff --git a/src/plugins/geolocation/geolocation_plugin.c b/src/plugins/geolocation/geolocation_plugin.c index c70d5b9f8..ed5fc87d9 100644 --- a/src/plugins/geolocation/geolocation_plugin.c +++ b/src/plugins/geolocation/geolocation_plugin.c @@ -150,7 +150,7 @@ static HeaderEntry hentry[] = { static gchar* get_ip_from_msginfo(MsgInfo *msginfo) { gchar *file; - struct stat ss; + GStatBuf ss; FILE *fp; gchar buf[BUFFSIZE]; gint hnum; diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c index 54227ed09..3088fa262 100644 --- a/src/plugins/libravatar/libravatar.c +++ b/src/plugins/libravatar/libravatar.c @@ -210,7 +210,7 @@ static GtkWidget *image_widget_from_url(const gchar *url, const gchar *md5) static gboolean is_recent_enough(const gchar *filename) { - struct stat s; + GStatBuf s; time_t t; if (libravatarprefs.cache_icons) { diff --git a/src/plugins/mailmbox/maillock.c b/src/plugins/mailmbox/maillock.c index 84e569858..475070fd1 100644 --- a/src/plugins/mailmbox/maillock.c +++ b/src/plugins/mailmbox/maillock.c @@ -173,7 +173,7 @@ static int lock_common(const char * filename, int fd, short locktype) time(&start); while (1) { int fd; - struct stat st; + GStatBuf st; time_t now; /* global timeout */ @@ -195,7 +195,7 @@ static int lock_common(const char * filename, int fd, short locktype) /* libEtPan! - adds a delay of 5 seconds between each tries */ sleep(5); - if (stat(lockfilename, &st) < 0) { + if (g_stat(lockfilename, &st) < 0) { if (statfailed++ > 5) { res = -1; goto unlock; diff --git a/src/plugins/mailmbox/mailmbox.c b/src/plugins/mailmbox/mailmbox.c index 3de488d80..3c4ada57d 100644 --- a/src/plugins/mailmbox/mailmbox.c +++ b/src/plugins/mailmbox/mailmbox.c @@ -130,11 +130,11 @@ int claws_mailmbox_read_unlock(struct claws_mailmbox_folder * folder) int claws_mailmbox_map(struct claws_mailmbox_folder * folder) { char * str; - struct stat buf; + GStatBuf buf; int res; int r; - r = stat(folder->mb_filename, &buf); + r = g_stat(folder->mb_filename, &buf); if (r < 0) { debug_print("stat failed %d\n", r); res = MAILMBOX_ERROR_FILE; @@ -187,9 +187,9 @@ void claws_mailmbox_sync(struct claws_mailmbox_folder * folder) void claws_mailmbox_timestamp(struct claws_mailmbox_folder * folder) { int r; - struct stat buf; + GStatBuf buf; - r = stat(folder->mb_filename, &buf); + r = g_stat(folder->mb_filename, &buf); if (r < 0) folder->mb_mtime = (time_t) -1; else @@ -238,11 +238,11 @@ static int claws_mailmbox_validate_lock(struct claws_mailmbox_folder * folder, int (* custom_lock)(struct claws_mailmbox_folder *), int (* custom_unlock)(struct claws_mailmbox_folder *)) { - struct stat buf; + GStatBuf buf; int res; int r; - r = stat(folder->mb_filename, &buf); + r = g_stat(folder->mb_filename, &buf); if (r < 0) { buf.st_mtime = (time_t) -1; } diff --git a/src/plugins/perl/perl_plugin.c b/src/plugins/perl/perl_plugin.c index 767e84838..6db4c412d 100644 --- a/src/plugins/perl/perl_plugin.c +++ b/src/plugins/perl/perl_plugin.c @@ -248,13 +248,13 @@ static gboolean update_PerlPluginTimedSList(PerlPluginTimedSList *tl) { gboolean retVal; gchar *indexfile; - struct stat filestat; + GStatBuf filestat; if(tl->g_slist == NULL) return TRUE; indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL); - if((stat(indexfile,&filestat) == 0) && filestat.st_mtime <= tl->mtime) + if((g_stat(indexfile,&filestat) == 0) && filestat.st_mtime <= tl->mtime) retVal = FALSE; else retVal = TRUE; @@ -267,7 +267,7 @@ static gboolean update_PerlPluginTimedSList(PerlPluginTimedSList *tl) static void init_email_slist(void) { gchar *indexfile; - struct stat filestat; + GStatBuf filestat; if(email_slist->g_slist != NULL) { free_PerlPluginEmailEntry_slist(email_slist->g_slist); @@ -277,7 +277,7 @@ static void init_email_slist(void) addrindex_load_person_attribute(NULL,add_to_email_slist); indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL); - if(stat(indexfile,&filestat) == 0) + if(g_stat(indexfile,&filestat) == 0) email_slist->mtime = filestat.st_mtime; g_free(indexfile); debug_print("Initialisation of email slist completed\n"); @@ -424,7 +424,7 @@ static void insert_attribute_hash(gchar *attr) { PerlPluginTimedSList *tl; gchar *indexfile; - struct stat filestat; + GStatBuf filestat; /* Check if key exists. Free it if it does. */ if((tl = g_hash_table_lookup(attribute_hash,attr)) != NULL) { @@ -445,7 +445,7 @@ static void insert_attribute_hash(gchar *attr) addrindex_load_person_attribute(attribute_key,add_to_attribute_hash); indexfile = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRESSBOOK_INDEX_FILE, NULL); - if(stat(indexfile,&filestat) == 0) + if(g_stat(indexfile,&filestat) == 0) tl->mtime = filestat.st_mtime; g_free(indexfile); diff --git a/src/plugins/rssyl/parse822.c b/src/plugins/rssyl/parse822.c index 01a7f7b74..cb31e11ce 100644 --- a/src/plugins/rssyl/parse822.c +++ b/src/plugins/rssyl/parse822.c @@ -243,7 +243,7 @@ static void rssyl_folder_read_existing_real(RFolderItem *ritem) gchar *path = NULL, *fname = NULL; DIR *dp; struct dirent *d; - struct stat st; + GStatBuf st; gint num; FeedItem *item = NULL; RFeedCtx *ctx; diff --git a/src/plugins/rssyl/rssyl.c b/src/plugins/rssyl/rssyl.c index 6e2590aad..b76aeb7e4 100644 --- a/src/plugins/rssyl/rssyl.c +++ b/src/plugins/rssyl/rssyl.c @@ -688,7 +688,7 @@ static gint rssyl_get_num_list(Folder *folder, FolderItem *item, static gboolean rssyl_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo) { - struct stat s; + GStatBuf s; gchar *path = NULL; g_return_val_if_fail(folder != NULL, FALSE); diff --git a/src/plugins/tnef_parse/tnef_parse.c b/src/plugins/tnef_parse/tnef_parse.c index 0ce9c6b9c..4abd2c585 100644 --- a/src/plugins/tnef_parse/tnef_parse.c +++ b/src/plugins/tnef_parse/tnef_parse.c @@ -50,7 +50,7 @@ static MimeInfo *tnef_broken_mimeinfo(const gchar *reason) MimeInfo *sub_info = NULL; gchar *tmpfilename = NULL; FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); - struct stat statbuf; + GStatBuf statbuf; if (!fp) { g_free(tmpfilename); @@ -87,7 +87,7 @@ static MimeInfo *tnef_dump_file(const gchar *filename, char *data, size_t size) MimeInfo *sub_info = NULL; gchar *tmpfilename = NULL; FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); - struct stat statbuf; + GStatBuf statbuf; gchar *content_type = NULL; if (!fp) { g_free(tmpfilename); @@ -141,7 +141,7 @@ MimeInfo *tnef_parse_vcal(TNEFStruct *tnef) MimeInfo *sub_info = NULL; gchar *tmpfilename = NULL; FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); - struct stat statbuf; + GStatBuf statbuf; gboolean result = FALSE; if (!fp) { g_free(tmpfilename); @@ -181,7 +181,7 @@ MimeInfo *tnef_parse_vtask(TNEFStruct *tnef) MimeInfo *sub_info = NULL; gchar *tmpfilename = NULL; FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); - struct stat statbuf; + GStatBuf statbuf; gboolean result = FALSE; if (!fp) { g_free(tmpfilename); @@ -234,7 +234,7 @@ MimeInfo *tnef_parse_vcard(TNEFStruct *tnef) MimeInfo *sub_info = NULL; gchar *tmpfilename = NULL; FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); - struct stat statbuf; + GStatBuf statbuf; gboolean result = FALSE; if (!fp) { g_free(tmpfilename); diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c index e051b3e70..2c3aa8850 100644 --- a/src/plugins/vcalendar/vcal_folder.c +++ b/src/plugins/vcalendar/vcal_folder.c @@ -1123,7 +1123,7 @@ static gint vcal_remove_folder(Folder *folder, FolderItem *fitem) static gboolean vcal_scan_required(Folder *folder, FolderItem *item) { - struct stat s; + GStatBuf s; VCalFolderItem *vitem = (VCalFolderItem *)item; g_return_val_if_fail(item != NULL, FALSE); @@ -1143,7 +1143,7 @@ static gint vcal_folder_lock_count = 0; static void vcal_set_mtime(Folder *folder, FolderItem *item) { - struct stat s; + GStatBuf s; gchar *path = folder_item_get_path(item); if (folder->inbox != item) diff --git a/src/prefs_themes.c b/src/prefs_themes.c index 0b4ad1b1b..f6a62af9d 100644 --- a/src/prefs_themes.c +++ b/src/prefs_themes.c @@ -159,7 +159,7 @@ static void prefs_themes_file_install (const gchar *filename, gpointer data); static void prefs_themes_file_stats(const gchar *filename, gpointer data) { - struct stat s; + GStatBuf s; DirInfo *di = (DirInfo *)data; gint len; diff --git a/src/procheader.c b/src/procheader.c index 36298be71..5759eec3c 100644 --- a/src/procheader.c +++ b/src/procheader.c @@ -337,7 +337,7 @@ void procheader_get_header_fields(FILE *fp, HeaderEntry hentry[]) MsgInfo *procheader_parse_file(const gchar *file, MsgFlags flags, gboolean full, gboolean decrypted) { - struct stat s; + GStatBuf s; FILE *fp; MsgInfo *msginfo; diff --git a/src/procmime.c b/src/procmime.c index e15738d0c..b98e33340 100644 --- a/src/procmime.c +++ b/src/procmime.c @@ -314,7 +314,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo) gint readend; gchar *tmpfilename; FILE *outfp, *infp; - struct stat statbuf; + GStatBuf statbuf; gboolean tmp_file = FALSE; gboolean flowed = FALSE; gboolean delsp = FALSE; @@ -527,7 +527,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding) FILE *infp = NULL, *outfp; gint len; gchar *tmpfilename; - struct stat statbuf; + GStatBuf statbuf; gboolean err = FALSE; if (mimeinfo->content == MIMECONTENT_EMPTY) @@ -2167,7 +2167,7 @@ static void output_mime_structure(MimeInfo *mimeinfo, int indent) static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offset, gboolean short_scan) { MimeInfo *mimeinfo; - struct stat buf; + GStatBuf buf; if (g_stat(filename, &buf) < 0) { FILE_OP_ERROR(filename, "stat");