From 26b75830ab942bc9116e8769652afa24d0d9550d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 10 Aug 2015 18:00:07 +0100 Subject: Add dry run feature --- src/utils.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 0952744..85d26f2 100644 --- a/src/utils.c +++ b/src/utils.c @@ -48,7 +48,11 @@ FILE *genb_fopen(const char *fname, const char *mode) char *fpath; FILE *filef; - fpath = genb_fpath(fname); + if (options->dryrun) { + fpath = strdup("/dev/null"); + } else { + fpath = genb_fpath(fname); + } filef = fopen(fpath, mode); if (filef == NULL) { @@ -68,7 +72,11 @@ FILE *genb_fopen_tmp(const char *fname) char *fpath; FILE *filef; - fpath = genb_fpath_tmp(fname); + if (options->dryrun) { + fpath = strdup("/dev/null"); + } else { + fpath = genb_fpath_tmp(fname); + } filef = fopen(fpath, "w+"); if (filef == NULL) { @@ -92,6 +100,11 @@ int genb_fclose_tmp(FILE *filef_tmp, const char *fname) size_t trd; size_t frd; + if (options->dryrun) { + fclose(filef_tmp); + return 0; + } + fpath = genb_fpath(fname); tpath = genb_fpath_tmp(fname); -- cgit v1.2.3