Compare commits
No commits in common. "5f8d6b0c0b555fd02c5cef8949231077e9533e11" and "1d85ddd0e9cc2be81d2e5edad980578ee38f48ca" have entirely different histories.
5f8d6b0c0b
...
1d85ddd0e9
2 changed files with 4 additions and 65 deletions
|
@ -72,17 +72,6 @@ int write_list_datas_fn(void *data, void *ud) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_temp_filename_delete(char **tmpfilename) {
|
|
||||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
|
||||||
if (tmpfilename && *tmpfilename) {
|
|
||||||
unlink(*tmpfilename);
|
|
||||||
*tmpfilename = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_files_fn(void *data, void *ud) {
|
int write_files_fn(void *data, void *ud) {
|
||||||
const SDArchiverFileInfo *file_info = data;
|
const SDArchiverFileInfo *file_info = data;
|
||||||
SDArchiverState *state = ud;
|
SDArchiverState *state = ud;
|
||||||
|
@ -174,41 +163,6 @@ int write_files_fn(void *data, void *ud) {
|
||||||
close(pipe_into_cmd[0]);
|
close(pipe_into_cmd[0]);
|
||||||
close(pipe_outof_cmd[1]);
|
close(pipe_outof_cmd[1]);
|
||||||
|
|
||||||
int compressor_status;
|
|
||||||
int compressor_return_val;
|
|
||||||
int compressor_ret = waitpid(compressor_pid, &compressor_status, WNOHANG);
|
|
||||||
if (compressor_ret == compressor_pid) {
|
|
||||||
// Status is available.
|
|
||||||
if (WIFEXITED(compressor_status)) {
|
|
||||||
compressor_return_val = WEXITSTATUS(compressor_status);
|
|
||||||
if (compressor_return_val == 127) {
|
|
||||||
// Exec failed.
|
|
||||||
fprintf(stderr,
|
|
||||||
"WARNING: Exec failed (exec exit code 127)! Invalid "
|
|
||||||
"compressor cmd?\n");
|
|
||||||
return 1;
|
|
||||||
} else if (compressor_return_val == 0) {
|
|
||||||
// Immediately halted.
|
|
||||||
fprintf(stderr,
|
|
||||||
"WARNING: Exec failed (exec exit code 0)! Invalid "
|
|
||||||
"compressor cmd?\n");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
// Other status returned.
|
|
||||||
fprintf(stderr,
|
|
||||||
"WARNING: Exec failed (exec exit code %d)! Invalid "
|
|
||||||
"compressor cmd?\n",
|
|
||||||
compressor_return_val);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (compressor_ret == 0) {
|
|
||||||
// Probably still running, continue on.
|
|
||||||
} else {
|
|
||||||
// Error.
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write file to pipe, and read from other pipe.
|
// Write file to pipe, and read from other pipe.
|
||||||
char write_buf[1024];
|
char write_buf[1024];
|
||||||
char read_buf[1024];
|
char read_buf[1024];
|
||||||
|
@ -361,8 +315,6 @@ int write_files_fn(void *data, void *ud) {
|
||||||
// Get compressed file length.
|
// Get compressed file length.
|
||||||
// Compressed file should be at "temp_filename".
|
// Compressed file should be at "temp_filename".
|
||||||
tmp_fd = fopen(temp_filename, "rb");
|
tmp_fd = fopen(temp_filename, "rb");
|
||||||
__attribute__((cleanup(cleanup_temp_filename_delete))) char
|
|
||||||
*temp_filename_cleanup_reference = temp_filename;
|
|
||||||
long end;
|
long end;
|
||||||
if (fseek(tmp_fd, 0, SEEK_END) != 0) {
|
if (fseek(tmp_fd, 0, SEEK_END) != 0) {
|
||||||
// Error seeking.
|
// Error seeking.
|
||||||
|
@ -410,6 +362,7 @@ int write_files_fn(void *data, void *ud) {
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
free_FILE_helper(&tmp_fd);
|
free_FILE_helper(&tmp_fd);
|
||||||
|
unlink(temp_filename);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
uint16_t u16;
|
uint16_t u16;
|
||||||
|
@ -1251,13 +1204,13 @@ int simple_archiver_de_compress(int pipe_fd_in[2], int pipe_fd_out[2],
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
posix_spawn_file_actions_destroy(&file_actions);
|
||||||
close(pipe_fd_in[0]);
|
close(pipe_fd_in[0]);
|
||||||
close(pipe_fd_out[1]);
|
close(pipe_fd_out[1]);
|
||||||
return 4;
|
return 3;
|
||||||
} else if (posix_spawn_file_actions_addclose(&file_actions, pipe_fd_out[0]) !=
|
} else if (posix_spawn_file_actions_addclose(&file_actions, pipe_fd_out[0]) !=
|
||||||
0) {
|
0) {
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
posix_spawn_file_actions_destroy(&file_actions);
|
||||||
close(pipe_fd_in[0]);
|
close(pipe_fd_in[0]);
|
||||||
close(pipe_fd_out[1]);
|
close(pipe_fd_out[1]);
|
||||||
return 5;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((cleanup(
|
__attribute__((cleanup(
|
||||||
|
@ -1270,7 +1223,7 @@ int simple_archiver_de_compress(int pipe_fd_in[2], int pipe_fd_out[2],
|
||||||
close(pipe_fd_in[0]);
|
close(pipe_fd_in[0]);
|
||||||
close(pipe_fd_out[1]);
|
close(pipe_fd_out[1]);
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
posix_spawn_file_actions_destroy(&file_actions);
|
||||||
return 6;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
posix_spawn_file_actions_destroy(&file_actions);
|
posix_spawn_file_actions_destroy(&file_actions);
|
||||||
|
|
14
src/main.c
14
src/main.c
|
@ -18,13 +18,6 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "platforms.h"
|
|
||||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archiver.h"
|
#include "archiver.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
|
@ -85,13 +78,6 @@ int main(int argc, const char **argv) {
|
||||||
fprintf(stderr, " %s\n", error_str);
|
fprintf(stderr, " %s\n", error_str);
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
#if SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_COSMOPOLITAN || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \
|
|
||||||
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
|
|
||||||
if (ret != SDAS_SUCCESS) {
|
|
||||||
unlink(parsed.filename);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else if ((parsed.flags & 3) == 2) {
|
} else if ((parsed.flags & 3) == 2) {
|
||||||
FILE *file = fopen(parsed.filename, "rb");
|
FILE *file = fopen(parsed.filename, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|
Loading…
Reference in a new issue