diff options
author | Justus Winter <justus@g10code.com> | 2015-11-26 17:05:12 +0100 |
---|---|---|
committer | Justus Winter <justus@g10code.com> | 2015-11-26 17:05:12 +0100 |
commit | 676b2d7081291f7e47a66755ab07af259fea130b (patch) | |
tree | 302dda6bb3a06964c5ce2b8d2370e3a9bf3241bf /tools/gpgtar-extract.c | |
parent | tools/gpgtar: Handle '--gpg-args'. (diff) | |
download | gnupg2-676b2d7081291f7e47a66755ab07af259fea130b.tar.xz gnupg2-676b2d7081291f7e47a66755ab07af259fea130b.zip |
tools/gpgtar: Add '--dry-run'.
* tools/gpgtar-extract.c (extract_{regular,directory}): Honor
'--dry-run'.
* tools/gpgtar.c (enum cmd_and_opt_values): New value.
(opts): Add '--dry-run'.
(parse_arguments): Handle '--dry-run'.
* tools/gpgtar.h (opt): Add field 'dry_run'.
Signed-off-by: Justus Winter <justus@g10code.com>
Diffstat (limited to 'tools/gpgtar-extract.c')
-rw-r--r-- | tools/gpgtar-extract.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c index 3b73c8506..728737d78 100644 --- a/tools/gpgtar-extract.c +++ b/tools/gpgtar-extract.c @@ -53,7 +53,10 @@ extract_regular (estream_t stream, const char *dirname, else err = 0; - outfp = es_fopen (fname, "wb"); + if (opt.dry_run) + outfp = es_fopenmem (0, "wb"); + else + outfp = es_fopen (fname, "wb"); if (!outfp) { err = gpg_error_from_syserror (); @@ -120,7 +123,7 @@ extract_directory (const char *dirname, tar_header_t hdr) /* Note that we don't need to care about EEXIST because we always extract into a new hierarchy. */ - if (gnupg_mkdir (fname, "-rwx------")) + if (! opt.dry_run && gnupg_mkdir (fname, "-rwx------")) { err = gpg_error_from_syserror (); if (gpg_err_code (err) == GPG_ERR_ENOENT) |