Use 'GStatBuf' instead of 'struct stat' type where possible.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 5 Jun 2015 11:33:32 +0000 (13:33 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 5 Jun 2015 11:33:32 +0000 (13:33 +0200)
26 files changed:
src/addrbook.c
src/addrcache.c
src/addrharvest.c
src/common/template.c
src/common/utils.c
src/common/w32_stat.c
src/common/w32lib.h
src/compose.c
src/jpilot.c
src/mh.c
src/plugins/archive/archiver_gtk.c
src/plugins/archive/libarchive_archive.c
src/plugins/clamd/clamav_plugin.c
src/plugins/clamd/clamav_plugin_gtk.c
src/plugins/geolocation/geolocation_plugin.c
src/plugins/libravatar/libravatar.c
src/plugins/mailmbox/maillock.c
src/plugins/mailmbox/mailmbox.c
src/plugins/perl/perl_plugin.c
src/plugins/rssyl/parse822.c
src/plugins/rssyl/rssyl.c
src/plugins/tnef_parse/tnef_parse.c
src/plugins/vcalendar/vcal_folder.c
src/prefs_themes.c
src/procheader.c
src/procmime.c

index 04e6c8c6c101aac81308ca33d201e8b7d74ecff1..ec6a723f43a3e84ba6f766e6a7cd9e7a62d1de02 100644 (file)
@@ -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;
index eb99af15ab4d5c62bf5fa32b776d0ee77a68a95c..2765b41bb0ae8b081bcd17703c18339c2c256a02 100644 (file)
@@ -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;
index d862eca36a98863a3978b527233bf0f7b015b847..999dcda7a5fb4160a361d1290c36cb816634105a 100644 (file)
@@ -765,7 +765,7 @@ static void addrharvest_harvest_dir(
 {
        DIR *dp;
        struct dirent *d;
-       struct stat s;
+       GStatBuf s;
        gint num;
        int r;
 
index 683f26362185456563f85d8438cc4fd641c1a3a2..bac5c7f6c8c656cd043197075b485ffa492d051d 100644 (file)
@@ -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;
 
index 064d12a958c20fa669d30636e6da0a0df2447d02..a135a9952183f37e953e59daf38fa03e7394e629 100644 (file)
@@ -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;
 
index 087527440e4b42a8af8e423d6ef29ef3e607a5af..8abbec7cf7168e3f99688e08d1a9c06391712900 100644 (file)
@@ -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 );
 }
 
index 135883294153314de25203fff72bbd2d8faf1884..69e68dd88b1350731b63185ce5e249107e96d9df 100644 (file)
@@ -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 );
index 926a033a4c818cb02cb0d90e7e1abd4ae0438746..2cf8df88864e2f8dcf690fd4195f0e41a921ecbd 100644 (file)
@@ -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;
index a0ca9f335e8f906add12c064f5d420f0351f48a5..fde63ce372b242edb050e247211fe5b6022cdc8c 100644 (file)
@@ -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 */
index b3fbc9c3f614f601c8878d213cd46c5b3f203efa..d1f4410ba3154552bd1e88cee9c8d46090cd147e 100644 (file)
--- 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);
index 0bba669a71363d3250ff23cbaea0f2f85f4f7f63..447de796d12725023de9d6738a8215f026d2fa78 100644 (file)
@@ -657,7 +657,7 @@ static void show_result(struct ArchivePage* page) {
                N_COLUMNS
        };
 
-       struct stat st;
+       GStatBuf st;
        GtkListStore* list;
        GtkTreeIter iter;
        GtkTreeView* view;
index 1da945004616be25021eccab3b689621627bd52e..a0536d42d85a09aa580ae7f882f8db6fb1058894 100644 (file)
@@ -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];
index 4194869a91682784966d8745a0de83fc87ceb9dc..c363e959bde9bee08bad6e0920df791a77800ce3 100644 (file)
@@ -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) {
index f400f6d86702c6049b08b643edc20f5769ceb405..c2b29f56dcdd7dad4095c63e0a19de8b14984e30 100644 (file)
@@ -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;
index c70d5b9f89de15c23205a0b29bef94cb5e674707..ed5fc87d97b779152756890e4b59e57d7350c4b0 100644 (file)
@@ -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;
index 54227ed09e6c2b0577393c6bb6caf505967e80d2..3088fa262ad7352b390fa8364c6401013e0ef05a 100644 (file)
@@ -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) {
index 84e569858a6b3d802043b1ad7c373de9d452f5fb..475070fd151e13c6f57e40ca390c1674b69c47d5 100644 (file)
@@ -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;
index 3de488d80248e21499b20bcb61c63f4cb41e0f51..3c4ada57d6140b3a021be6f025fe432d8321cd7a 100644 (file)
@@ -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;
   }
index 767e848381990ac4c3aec10316279b88acf54474..6db4c412ddae78f07aa2570f95871cfb158c7ed1 100644 (file)
@@ -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);
 
index 01a7f7b74e713d43cadcd4c78975a6da014d6844..cb31e11cec870ee96ce9ce1f95af49c6892529b5 100644 (file)
@@ -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;
index 6e2590aadaf9a6bb031ef474d5fa4b8ec5b7f5a4..b76aeb7e48d1f6245cb78d0b52cdf2582f4302b2 100644 (file)
@@ -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);
index 0ce9c6b9c4b529da048eda40941a0595619e3cc0..4abd2c585e7741d39fd11ea9bf19367f4337b6ae 100644 (file)
@@ -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);
index e051b3e705599c9d66a93d9efd1b4e266071a743..2c3aa8850e6b0bc92aad6ecb6aa6726e6f5ce716 100644 (file)
@@ -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)
index 0b4ad1b1b4bfff5bd3484366aa840954e1975dfb..f6a62af9d333ac2e6117f0d4fbdb340764840460 100644 (file)
@@ -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;
        
index 36298be712d220ea4b40e440c0c99163dd525f82..5759eec3c6571b5008c6e91ad101c0c4f657ae68 100644 (file)
@@ -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;
 
index e15738d0c1170b8aa97ca0bd69e27a142d4e389b..b98e33340f54007c360132f70d80d5fc615e9a2b 100644 (file)
@@ -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");