mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-04-05 06:15:28 +00:00
Reinstate the temporary files for decompression to stdout and testing as the damaged line reinstated last commit meant it looked like those combinations worked when they actually didn't.
Compression from stdin still works without temporary files.
This commit is contained in:
parent
c464975b8d
commit
102140dc2b
4 changed files with 23 additions and 24 deletions
24
main.c
24
main.c
|
|
@ -291,31 +291,33 @@ static void decompress_file(void)
|
|||
|
||||
if (!NO_SET_PERMS)
|
||||
preserve_perms(fd_in, fd_out);
|
||||
fd_hist = open(control.outfile, O_RDONLY);
|
||||
if (fd_hist == -1)
|
||||
fatal("Failed to open history file %s\n", control.outfile);
|
||||
} else if (TEST_ONLY) {
|
||||
fd_out = open("/dev/null", O_WRONLY);
|
||||
fd_hist = open("/dev/zero", O_RDONLY);
|
||||
} else if (STDOUT) {
|
||||
fd_out = 1;
|
||||
fd_hist = 1;
|
||||
}
|
||||
} else
|
||||
fd_out = open_tmpoutfile();
|
||||
|
||||
fd_hist = open(control.outfile, O_RDONLY);
|
||||
read_magic(fd_in, &expected_size);
|
||||
print_progress("Decompressing...");
|
||||
|
||||
runzip_fd(fd_in, fd_out, fd_hist, expected_size);
|
||||
|
||||
if (STDOUT)
|
||||
dump_tmpoutfile(fd_out);
|
||||
|
||||
/* if we get here, no fatal errors during decompression */
|
||||
print_progress("\r");
|
||||
if (!(STDOUT | TEST_ONLY))
|
||||
print_output("Output filename is: %s: ", control.outfile);
|
||||
print_progress("[OK] - %lld bytes \n", expected_size);
|
||||
|
||||
if (!STDOUT) {
|
||||
if (close(fd_hist) != 0 || close(fd_out) != 0)
|
||||
fatal("Failed to close files\n");
|
||||
if (close(fd_hist) != 0 || close(fd_out) != 0)
|
||||
fatal("Failed to close files\n");
|
||||
|
||||
if (TEST_ONLY | STDOUT) {
|
||||
/* Delete temporary files generated for testing or faking stdout */
|
||||
if (unlink(control.outfile) != 0)
|
||||
fatal("Failed to unlink tmpfile: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
close(fd_in);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue