Mercurial > geeqie.yaz
changeset 536:d8494488d2d2
Add a wrapper to fwrite().
author | zas_ |
---|---|
date | Thu, 01 May 2008 22:27:44 +0000 |
parents | 8123d713dd3f |
children | 8d9992e2de56 |
files | src/secure_save.c src/secure_save.h |
diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/secure_save.c Thu May 01 21:42:22 2008 +0000 +++ b/src/secure_save.c Thu May 01 22:27:44 2008 +0000 @@ -370,6 +370,26 @@ return ret; } +/** fwrite() wrapper, set ssi->err to errno on error and return a value less than + * the number of elements to write. If ssi->err is set when called, it immediatly returns 0. + */ +size_t +secure_fwrite(const void *ptr, size_t size, size_t nmemb, SecureSaveInfo *ssi) +{ + size_t ret; + + if (!ssi || !ssi->fp || ssi->err) return 0; + + ret = fwrite(ptr, size, nmemb, ssi->fp); + if (ret < nmemb) + { + ssi->err = errno; + secsave_errno = SS_ERR_OTHER; + } + + return ret; +} + gchar * secsave_strerror(SecureSaveErrno secsave_error) {
--- a/src/secure_save.h Thu May 01 21:42:22 2008 +0000 +++ b/src/secure_save.h Thu May 01 22:27:44 2008 +0000 @@ -22,6 +22,7 @@ gint secure_fputc(SecureSaveInfo *, gint); gint secure_fprintf(SecureSaveInfo *, const gchar *, ...); +size_t secure_fwrite(const void *ptr, size_t size, size_t nmemb, SecureSaveInfo *ssi); gchar *secsave_strerror(SecureSaveErrno);