Mercurial > hg > th-libs
changeset 460:0a1a65503e0b
Use a macro for updating atime.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 17 Feb 2018 23:41:11 +0200 |
parents | 7fca448847a3 |
children | 04320ca79407 |
files | th_ioctx.c |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/th_ioctx.c Sat Feb 17 23:35:20 2018 +0200 +++ b/th_ioctx.c Sat Feb 17 23:41:11 2018 +0200 @@ -11,6 +11,9 @@ #include <stdio.h> +#define TH_UPDATE_ATIME do { ctx->atime = time(NULL); } while (0) + + th_ioctx *th_io_new(const th_ioctx_ops *fops, const char *filename) { th_ioctx *ctx = th_malloc0(sizeof(th_ioctx)); @@ -150,63 +153,63 @@ int thferror(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->ferror(ctx); } int thfseek(th_ioctx *ctx, const off_t offset, int whence) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fseek(ctx, offset, whence); } off_t thfsize(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fsize(ctx); } off_t thftell(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->ftell(ctx); } BOOL thfeof(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->feof(ctx); } int thfgetc(th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fgetc(ctx); } int thfputc(int v, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fputc(v, ctx); } size_t thfread(void *ptr, size_t size, size_t nmemb, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fread(ptr, size, nmemb, ctx); } size_t thfwrite(const void *ptr, size_t size, size_t nmemb, th_ioctx *ctx) { - ctx->atime = time(NULL); + TH_UPDATE_ATIME; return ctx->fops->fwrite(ptr, size, nmemb, ctx); }