forked from steve-clarke/mergetars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmergetars.c
38 lines (32 loc) · 895 Bytes
/
mergetars.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "mergetars.h"
int main(int argc, char *argv[])
{
// Check number of arguments
if (argc < 3)
{
fprintf(stderr, "Usage: %s input_archive1.tar [input_archive2.tar ... ] output_file.tar\n",
argv[0]);
exit(EXIT_FAILURE);
}
// Check if -v flag is present
if(strcmp(argv[1], "-v") == 0)
{
verbosemode = true;
--argc;
++argv;
}
// Expand each .tar file into a new temp directory
for(int i = 1; i < argc-1 ; i++)
{
if(expand_tarfile(argv[i]) != 0)
{
cleanup(EXIT_FAILURE);
}
}
// populate struct with appropriate files and directory structure
merge();
// Make output file based on information from merge() call
populate_output(argv[argc-1]);
// Perform cleanup of all tmp directories and frees memory
cleanup(EXIT_SUCCESS);
}