]> granicus.if.org Git - neomutt/commitdiff
move file_get_size
authorRichard Russon <rich@flatcap.org>
Thu, 27 Sep 2018 19:27:46 +0000 (20:27 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 29 Sep 2018 22:05:35 +0000 (23:05 +0100)
compress.c
mutt/file.c
mutt/file.h

index 899fdeea563a4bc9dd599fa652e1d01ee2950012..e91d315c559a8a68e8671e076524ce9266320667 100644 (file)
@@ -173,24 +173,6 @@ static int setup_paths(struct Mailbox *mailbox)
   return 0;
 }
 
-/**
- * get_size - Get the size of a file
- * @param path File to measure
- * @retval num Size in bytes
- * @retval 0   Error
- */
-static long get_size(const char *path)
-{
-  if (!path)
-    return 0;
-
-  struct stat sb;
-  if (stat(path, &sb) != 0)
-    return 0;
-
-  return sb.st_size;
-}
-
 /**
  * store_size - Save the size of the compressed file
  * @param mailbox Mailbox
@@ -206,7 +188,7 @@ static void store_size(const struct Mailbox *mailbox)
   if (!ci)
     return;
 
-  ci->size = get_size(mailbox->realpath);
+  ci->size = mutt_file_get_size(mailbox->realpath);
 }
 
 /**
@@ -599,7 +581,7 @@ static int comp_mbox_open_append(struct Context *ctx, int flags)
   }
 
   /* Open the existing mailbox, unless we are appending */
-  if (!ci->append && (get_size(ctx->mailbox->realpath) > 0))
+  if (!ci->append && (mutt_file_get_size(ctx->mailbox->realpath) > 0))
   {
     int rc = execute_command(ctx->mailbox, ci->open, _("Decompressing %s"));
     if (rc == 0)
@@ -669,7 +651,7 @@ static int comp_mbox_check(struct Context *ctx, int *index_hint)
   if (!ops)
     return -1;
 
-  int size = get_size(ctx->mailbox->realpath);
+  int size = mutt_file_get_size(ctx->mailbox->realpath);
   if (size == ci->size)
     return 0;
 
index d8cae66e4cb96855cae5e3e2a4d034b50c89ca18..46e92b180fabcbaa53c8d4bade376617f2341e1f 100644 (file)
@@ -1335,3 +1335,21 @@ void mutt_file_expand_fmt(char *dest, size_t destlen, const char *fmt, const cha
     mutt_str_strcat(dest, destlen, src);
   }
 }
+
+/**
+ * mutt_file_get_size - Get the size of a file
+ * @param path File to measure
+ * @retval num Size in bytes
+ * @retval 0   Error
+ */
+long mutt_file_get_size(const char *path)
+{
+  if (!path)
+    return 0;
+
+  struct stat sb;
+  if (stat(path, &sb) != 0)
+    return 0;
+
+  return sb.st_size;
+}
index 7776fef03b16dcf7a4c390a05928169bb9e6eb7a..b857c1d3b72fd91416878494d18e027be0390a68 100644 (file)
@@ -49,6 +49,7 @@ void        mutt_file_expand_fmt_quote(char *dest, size_t destlen, const char *f
 int         mutt_file_fclose(FILE **f);
 FILE *      mutt_file_fopen(const char *path, const char *mode);
 int         mutt_file_fsync_close(FILE **f);
+long        mutt_file_get_size(const char *path);
 int         mutt_file_lock(int fd, bool excl, bool timeout);
 int         mutt_file_mkdir(const char *path, mode_t mode);
 FILE *      mutt_file_mkstemp_full(const char *file, int line, const char *func);