From: Colin Leroy Date: Sun, 7 Oct 2018 18:41:20 +0000 (+0200) Subject: Make safe_fclose static now that it can be X-Git-Tag: 3.17.2~105 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=e745553712a30022d6d34602b4279604df0ce945 Make safe_fclose static now that it can be --- diff --git a/src/common/file-utils.c b/src/common/file-utils.c index 8f58fece8..0d6d227d4 100644 --- a/src/common/file-utils.c +++ b/src/common/file-utils.c @@ -34,8 +34,7 @@ gboolean prefs_common_get_flush_metadata(void); gboolean prefs_common_get_use_shred(void); -/* FIXME make static once every file I/O is done using claws_* wrappers */ -int safe_fclose(FILE *fp) +static int safe_fclose(FILE *fp) { int r; START_TIMING(""); @@ -53,6 +52,18 @@ int safe_fclose(FILE *fp) return r; } +/* Unlock, then safe-close a file pointer + * Safe close is done using fflush + fsync + * if the according preference says so. + */ +int claws_safe_fclose(FILE *fp) +{ +#if HAVE_FGETS_UNLOCKED + funlockfile(fp); +#endif + return safe_fclose(fp); +} + #if HAVE_FGETS_UNLOCKED /* Open a file and locks it once @@ -84,16 +95,7 @@ int claws_fclose(FILE *fp) funlockfile(fp); return fclose(fp); } - -/* Unlock, then safe-close a file pointer - * Safe close is done using fflush + fsync - * if the according preference says so. - */ -int claws_safe_fclose(FILE *fp) -{ - funlockfile(fp); - return safe_fclose(fp); -} +#endif #ifdef G_OS_WIN32 #define WEXITSTATUS(x) (x) @@ -875,5 +877,3 @@ FILE *str_open_as_stream(const gchar *str) rewind(fp); return fp; } - -#endif diff --git a/src/common/file-utils.h b/src/common/file-utils.h index 10926f055..398bfde27 100644 --- a/src/common/file-utils.h +++ b/src/common/file-utils.h @@ -42,7 +42,6 @@ FILE *claws_fopen (const char *file, FILE *claws_fdopen (int fd, const char *mode); int claws_fclose (FILE *fp); -int claws_safe_fclose (FILE *fp); #else @@ -57,10 +56,9 @@ int claws_safe_fclose (FILE *fp); #define claws_fopen g_fopen #define claws_fdopen fdopen #define claws_fclose fclose -#define claws_safe_fclose safe_fclose #endif -int safe_fclose (FILE *fp); +int claws_safe_fclose (FILE *fp); int claws_unlink (const char *filename); gint file_strip_crs (const gchar *file);