more fixes, et je crois que la nouvelle testsuite est kc
This commit is contained in:
parent
8ec0d9a4ee
commit
c6408716d5
4 changed files with 22 additions and 10 deletions
|
|
@ -12,10 +12,6 @@ static int handle_err_code(enum error_code err, struct config *config)
|
||||||
ret_code = 0;
|
ret_code = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case UNKNOWN_ERROR:
|
|
||||||
// printf("epitar: error extracting tarball %s\n",
|
|
||||||
// config.archive_file); ret_code = 3; break;
|
|
||||||
|
|
||||||
case BAD_CHECKSUM:
|
case BAD_CHECKSUM:
|
||||||
puts("epitar: bad checksum");
|
puts("epitar: bad checksum");
|
||||||
ret_code = 2;
|
ret_code = 2;
|
||||||
|
|
@ -37,8 +33,17 @@ static int handle_err_code(enum error_code err, struct config *config)
|
||||||
__attribute__((fallthrough));
|
__attribute__((fallthrough));
|
||||||
|
|
||||||
case EMPTY_ARCHIVE:
|
case EMPTY_ARCHIVE:
|
||||||
puts("epitar: cowardly refusing to create an empty archive");
|
if (config->mode == ARCHIVE)
|
||||||
ret_code = 1;
|
{
|
||||||
|
puts("epitar: cowardly refusing to create an empty archive");
|
||||||
|
ret_code = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("epitar: error extracting tarball %s\n",
|
||||||
|
config->archive_file);
|
||||||
|
ret_code = 3;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ static enum error_code archivefile(FILE *archive, char *file_path, bool verbose)
|
||||||
FILE *file = fopen(file_path, "r");
|
FILE *file = fopen(file_path, "r");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
printf("Unable to add file %s", file_path);
|
printf("unable to add file %s", file_path);
|
||||||
return FILE_NOT_FOUND;
|
return FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ static enum error_code archivedir(FILE *archive, char *dir_path, bool verbose)
|
||||||
if (isdir == FILE_NOT_FOUND)
|
if (isdir == FILE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
// Does not exists
|
// Does not exists
|
||||||
printf("Unable to add file %s", dir_path);
|
printf("unable to add file %s", dir_path);
|
||||||
err = FILE_NOT_FOUND;
|
err = FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
else if (isdir == SUCCESS)
|
else if (isdir == SUCCESS)
|
||||||
|
|
@ -204,7 +204,7 @@ enum error_code archive(char *archive_name, char **files, bool verbose)
|
||||||
if (isdir == FILE_NOT_FOUND)
|
if (isdir == FILE_NOT_FOUND)
|
||||||
{
|
{
|
||||||
// Does not exists
|
// Does not exists
|
||||||
printf("Unable to add file %s", *current_file);
|
printf("unable to add file %s", *current_file);
|
||||||
err = FILE_NOT_FOUND;
|
err = FILE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
else if (isdir == SUCCESS)
|
else if (isdir == SUCCESS)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../utils/filesystem.h"
|
#include "../utils/filesystem.h"
|
||||||
|
#include "tar.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -135,6 +136,12 @@ enum error_code extract(char *archive_name, bool verbose)
|
||||||
got_empty_block = false;
|
got_empty_block = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_checksum(&header))
|
||||||
|
{
|
||||||
|
fclose(stream);
|
||||||
|
return BAD_CHECKSUM;
|
||||||
|
}
|
||||||
|
|
||||||
// Extract file
|
// Extract file
|
||||||
enum error_code err = extract_file(stream, &header, verbose);
|
enum error_code err = extract_file(stream, &header, verbose);
|
||||||
if (err != SUCCESS)
|
if (err != SUCCESS)
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ enum arg_error_code args_handler(int argc, char **argv, struct config *config)
|
||||||
|
|
||||||
// Parse option flags
|
// Parse option flags
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "cxvh")) != -1)
|
while ((opt = getopt(argc, argv, ":cvxh")) != -1)
|
||||||
{
|
{
|
||||||
int err = handle_opt(opt, config);
|
int err = handle_opt(opt, config);
|
||||||
if (err == ARG_HELP)
|
if (err == ARG_HELP)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue