Author: David Frey Description: Maintain modification times. --- a/main.c +++ b/main.c @@ -128,6 +128,8 @@ static void decompress_file(struct rzip_ { int fd_in, fd_out = -1, fd_hist = -1; off_t expected_size; + struct stat sb; + struct utimbuf utb; if (control->outname) { control->outfile = strdup(control->outname); @@ -143,6 +145,8 @@ static void decompress_file(struct rzip_ control->outfile[strlen(control->infile) - strlen(control->suffix)] = 0; } + stat(control->infile,&sb); + fd_in = open(control->infile,O_RDONLY); if (fd_in == -1) { fatal("Failed to open %s: %s\n", @@ -190,6 +194,10 @@ static void decompress_file(struct rzip_ } } + utb.actime=sb.st_atime; + utb.modtime=sb.st_mtime; + utime(control->outfile,&utb); + free(control->outfile); } @@ -199,6 +207,8 @@ static void decompress_file(struct rzip_ static void compress_file(struct rzip_control *control) { int fd_in, fd_out; + struct stat sb; + struct utimbuf utb; if (strlen(control->suffix) <= strlen(control->infile) && strcmp(control->suffix, control->infile + strlen(control->infile) - strlen(control->suffix)) == 0) { @@ -218,6 +228,8 @@ static void compress_file(struct rzip_co strcat(control->outfile, control->suffix); } + stat(control->infile,&sb); + fd_in = open(control->infile,O_RDONLY); if (fd_in == -1) { fatal("Failed to open %s: %s\n", control->infile, strerror(errno)); @@ -248,6 +260,10 @@ static void compress_file(struct rzip_co } } + utb.actime=sb.st_atime; + utb.modtime=sb.st_mtime; + utime(control->outfile,&utb); + free(control->outfile); } --- a/rzip.h +++ b/rzip.h @@ -33,6 +33,8 @@ #include #include #include +#include +#include #ifdef HAVE_STRING_H #include