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
if (!ci)
return;
- ci->size = get_size(mailbox->realpath);
+ ci->size = mutt_file_get_size(mailbox->realpath);
}
/**
}
/* 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)
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;
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;
+}
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);