[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch to gzip-1.3.9 for adding "keep input files" feature - version 2
From: |
Shriramana Sharma |
Subject: |
Patch to gzip-1.3.9 for adding "keep input files" feature - version 2 |
Date: |
Sun, 18 Feb 2007 09:28:16 +0530 |
User-agent: |
Thunderbird 1.5.0.9 (Windows/20061207) |
The previous version of the patch would not preserve the permissions,
ownership and timestamps. So I corrected that.
Shriramana Sharma.
--- gzip-1.3.9/gzip.c 2006-12-12 05:33:17.000000000 +0530
+++ gzip-1.3.9-2shriramana2/gzip.c 2007-02-13 18:37:23.000000000 +0530
@@ -196,6 +196,7 @@
int recursive = 0; /* recurse through directories (-r) */
int list = 0; /* list the file contents (-l) */
int verbose = 0; /* be verbose (-v) */
+int keep_input_files = 0; /* do not delete input files */
int quiet = 0; /* be very quiet (-q) */
int do_lzw = 0; /* generate output compatible with old compress (-Z) */
int test = 0; /* test .gz file integrity */
@@ -238,6 +239,7 @@
unsigned insize; /* valid bytes in inbuf */
unsigned inptr; /* index of next byte to be processed in inbuf */
unsigned outcnt; /* bytes in output buffer */
+int rsync = 0; /* make ryncable chunks */
struct option longopts[] =
{
@@ -250,7 +252,8 @@
/* {"encrypt", 0, 0, 'e'}, encrypt */
{"force", 0, 0, 'f'}, /* force overwrite of output file */
{"help", 0, 0, 'h'}, /* give help */
- /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */
+ /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */ /* IF THIS
IS ENABLED IT WILL CONFLICT WITH "KEEP" */
+ {"keep", 0, 0, 'k'}, /* keep input files */
{"list", 0, 0, 'l'}, /* list .gz file contents */
{"license", 0, 0, 'L'}, /* display software license */
{"no-name", 0, 0, 'n'}, /* don't save or restore original name & time */
@@ -267,6 +270,7 @@
{"best", 0, 0, '9'}, /* compress better */
{"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */
{"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */
+ {"rsyncable", 0, 0, 'R'}, /* make rsync-friendly archive */
{ 0, 0, 0, 0 }
};
@@ -325,7 +329,8 @@
/* -e, --encrypt encrypt */
" -f, --force force overwrite of output file and compress links",
" -h, --help give this help",
-/* -k, --pkzip force output in pkzip format */
+/* -k, --pkzip force output in pkzip format */ /* IF THIS IS ENABLED IT
WILL CONFLICT WITH "KEEP" */
+ " -k, --keep keep (don't delete) input files",
" -l, --list list compressed file contents",
" -L, --license display software license",
#ifdef UNDOCUMENTED
@@ -348,6 +353,7 @@
" -Z, --lzw produce output compatible with old compress",
" -b, --bits=BITS max number of bits per code (implies -Z)",
#endif
+ " --rsyncable Make rsync-friendly archive",
"",
"With no FILE, or when FILE is -, read standard input.",
"",
@@ -421,13 +427,13 @@
decompress = 1;
else if (strequ (program_name + 1, "cat") /* zcat, pcat, gcat */
|| strequ (program_name, "gzcat")) /* gzcat */
- decompress = to_stdout = 1;
+ decompress = to_stdout = keep_input_files = 1;
#endif
z_suffix = Z_SUFFIX;
z_len = strlen(z_suffix);
- while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789",
+ while ((optc = getopt_long (argc, argv,
"ab:cdfhH?klLmMnNqrS:tvVZ123456789",
longopts, (int *)0)) != -1) {
switch (optc) {
case 'a':
@@ -443,15 +449,17 @@
}
break;
case 'c':
- to_stdout = 1; break;
+ to_stdout = keep_input_files = 1; break;
case 'd':
decompress = 1; break;
+ case 'k':
+ keep_input_files = 1; break;
case 'f':
force++; break;
case 'h': case 'H':
help(); do_exit(OK); break;
case 'l':
- list = decompress = to_stdout = 1; break;
+ list = decompress = to_stdout = keep_input_files = 1; break;
case 'L':
license(); do_exit(OK); break;
case 'm': /* undocumented, may change later */
@@ -472,7 +480,9 @@
#else
recursive = 1;
#endif
- break;
+ case 'R':
+ rsync = 1; break;
+
case 'S':
#ifdef NO_MULTIPLE_DOTS
if (*optarg == '.') optarg++;
@@ -481,7 +491,7 @@
z_suffix = optarg;
break;
case 't':
- test = decompress = to_stdout = 1;
+ test = decompress = to_stdout = keep_input_files = 1;
break;
case 'v':
verbose++; quiet = 0; break;
@@ -740,7 +750,7 @@
return;
}
- if (istat.st_nlink > 1 && !to_stdout && !force) {
+ if (istat.st_nlink > 1 && !keep_input_files && !force) {
WARN((stderr, "%s: %s has %lu other link%c -- unchanged\n",
program_name, ifname, (unsigned long) istat.st_nlink - 1,
istat.st_nlink > 2 ? 's' : ' '));
@@ -823,12 +833,13 @@
if (close (ifd) != 0)
read_error ();
- if (!to_stdout)
+ if (!to_stdout) copy_stat (&istat);
+
+ if (!keep_input_files)
{
sigset_t oldset;
int unlink_errno;
- copy_stat (&istat);
if (close (ofd) != 0)
write_error ();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patch to gzip-1.3.9 for adding "keep input files" feature - version 2,
Shriramana Sharma <=