diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2011-02-04 11:29:47 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2011-02-04 11:29:47 +0200 |
commit | 6decc8b41882c2250f0450eb87b83c9fbf495e95 (patch) | |
tree | c1b2725119408c048f6f899b87b83a9bf3cc6eab /src/xz/suffix.c | |
parent | Updated THANKS. (diff) | |
download | xz-6decc8b41882c2250f0450eb87b83c9fbf495e95.tar.xz |
xz: Check if the file already has custom suffix when compressing.
Now "xz -S .test foo.test" refuses to compress the
file because it already has the suffix .test. The man
page had it documented this way already.
Diffstat (limited to 'src/xz/suffix.c')
-rw-r--r-- | src/xz/suffix.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/xz/suffix.c b/src/xz/suffix.c index ea86c1a3..f795e2ad 100644 --- a/src/xz/suffix.c +++ b/src/xz/suffix.c @@ -183,6 +183,15 @@ compressed_name(const char *src_name, const size_t src_len) } } + if (custom_suffix != NULL) { + if (test_suffix(custom_suffix, src_name, src_len) != 0) { + message_warning(_("%s: File already has `%s' " + "suffix, skipping"), src_name, + custom_suffix); + return NULL; + } + } + // TODO: Hmm, maybe it would be better to validate this in args.c, // since the suffix handling when decoding is weird now. if (opt_format == FORMAT_RAW && custom_suffix == NULL) { |