Fix extracting when no compressor was used
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 4s
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 4s
This commit is contained in:
parent
4cb4184338
commit
5b3a7e3994
1 changed files with 131 additions and 98 deletions
|
@ -831,9 +831,11 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
|
||||
if (do_extract && !skip) {
|
||||
fprintf(stderr, " Extracting...\n");
|
||||
|
||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
||||
if (is_compressed) {
|
||||
int pipe_into_cmd[2];
|
||||
int pipe_outof_cmd[2];
|
||||
pid_t decompressor_pid;
|
||||
|
@ -965,6 +967,37 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract,
|
|||
}
|
||||
|
||||
waitpid(decompressor_pid, NULL, 0);
|
||||
} else {
|
||||
uint64_t compressed_file_size = u64;
|
||||
ssize_t fread_ret;
|
||||
while (compressed_file_size != 0) {
|
||||
if (compressed_file_size > 1024) {
|
||||
fread_ret = fread(buf, 1, 1024, in_f);
|
||||
if (ferror(in_f)) {
|
||||
// Error.
|
||||
return 1;
|
||||
}
|
||||
fwrite(buf, 1, fread_ret, out_f);
|
||||
if (ferror(out_f)) {
|
||||
// Error.
|
||||
return 1;
|
||||
}
|
||||
compressed_file_size -= fread_ret;
|
||||
} else {
|
||||
fread_ret = fread(buf, 1, compressed_file_size, in_f);
|
||||
if (ferror(in_f)) {
|
||||
// Error.
|
||||
return 1;
|
||||
}
|
||||
fwrite(buf, 1, fread_ret, out_f);
|
||||
if (ferror(out_f)) {
|
||||
// Error.
|
||||
return 1;
|
||||
}
|
||||
compressed_file_size -= fread_ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (chmod((const char *)out_f_name, permissions) == -1) {
|
||||
// Error.
|
||||
|
|
Loading…
Reference in a new issue