aboutsummaryrefslogtreecommitdiff
path: root/archival/bbunzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/bbunzip.c')
-rw-r--r--archival/bbunzip.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index c7962058e..75489f2a5 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -30,13 +30,14 @@ int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
30 30
31int FAST_FUNC bbunpack(char **argv, 31int FAST_FUNC bbunpack(char **argv,
32 char* (*make_new_name)(char *filename), 32 char* (*make_new_name)(char *filename),
33 USE_DESKTOP(long long) int (*unpacker)(void) 33 USE_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
34) 34)
35{ 35{
36 struct stat stat_buf; 36 struct stat stat_buf;
37 USE_DESKTOP(long long) int status; 37 USE_DESKTOP(long long) int status;
38 char *filename, *new_name; 38 char *filename, *new_name;
39 smallint exitcode = 0; 39 smallint exitcode = 0;
40 unpack_info_t info;
40 41
41 do { 42 do {
42 /* NB: new_name is *maybe* malloc'ed! */ 43 /* NB: new_name is *maybe* malloc'ed! */
@@ -92,14 +93,29 @@ int FAST_FUNC bbunpack(char **argv,
92 "use -f to force it"); 93 "use -f to force it");
93 } 94 }
94 95
95 status = unpacker(); 96 /* memset(&info, 0, sizeof(info)); */
97 info.mtime = 0; /* so far it has one member only */
98 status = unpacker(&info);
96 if (status < 0) 99 if (status < 0)
97 exitcode = 1; 100 exitcode = 1;
98 101
99 if (filename) { 102 if (filename) {
100 char *del = new_name; 103 char *del = new_name;
101 if (status >= 0) { 104 if (status >= 0) {
102 /* TODO: restore user/group/times here? */ 105 /* TODO: restore other things? */
106 if (info.mtime) {
107 struct utimbuf times;
108
109 times.actime = info.mtime;
110 times.modtime = info.mtime;
111 /* Close first.
112 * On some systems calling utime
113 * then closing resets the mtime. */
114 close(STDOUT_FILENO);
115 /* Ignoring errors */
116 utime(new_name, &times);
117 }
118
103 /* Delete _compressed_ file */ 119 /* Delete _compressed_ file */
104 del = filename; 120 del = filename;
105 /* restore extension (unless tgz -> tar case) */ 121 /* restore extension (unless tgz -> tar case) */
@@ -159,7 +175,7 @@ char* make_new_name_bunzip2(char *filename)
159} 175}
160 176
161static 177static
162USE_DESKTOP(long long) int unpack_bunzip2(void) 178USE_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
163{ 179{
164 return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO); 180 return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
165} 181}
@@ -235,7 +251,7 @@ char* make_new_name_gunzip(char *filename)
235} 251}
236 252
237static 253static
238USE_DESKTOP(long long) int unpack_gunzip(void) 254USE_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
239{ 255{
240 USE_DESKTOP(long long) int status = -1; 256 USE_DESKTOP(long long) int status = -1;
241 257
@@ -247,7 +263,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
247 if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) { 263 if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
248 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO); 264 status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
249 } else if (magic2 == 0x8b) { 265 } else if (magic2 == 0x8b) {
250 status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO); 266 status = unpack_gz_stream_with_info(STDIN_FILENO, STDOUT_FILENO, info);
251 } else { 267 } else {
252 goto bad_magic; 268 goto bad_magic;
253 } 269 }
@@ -309,7 +325,7 @@ char* make_new_name_unlzma(char *filename)
309} 325}
310 326
311static 327static
312USE_DESKTOP(long long) int unpack_unlzma(void) 328USE_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
313{ 329{
314 return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO); 330 return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
315} 331}
@@ -344,7 +360,7 @@ char* make_new_name_uncompress(char *filename)
344} 360}
345 361
346static 362static
347USE_DESKTOP(long long) int unpack_uncompress(void) 363USE_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
348{ 364{
349 USE_DESKTOP(long long) int status = -1; 365 USE_DESKTOP(long long) int status = -1;
350 366