Compare commits
No commits in common. "master" and "epitar-submission-1" have entirely different histories.
master
...
epitar-sub
6 changed files with 12 additions and 40 deletions
|
|
@ -22,7 +22,7 @@ $(TARGET): $(OBJS)
|
|||
@echo $(OBJS)
|
||||
|
||||
all: $(OBJS)
|
||||
$(CC) -o $(TARGET) $^ $(LDFLAGS) $(LDLIBS)
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
|
||||
|
||||
debug: CFLAGS += $(DBG_CFLAGS)
|
||||
debug: LDFLAGS += $(DBG_LDFLAGS)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ static int handle_err_code(enum error_code err, struct config *config)
|
|||
ret_code = 0;
|
||||
break;
|
||||
|
||||
// case UNKNOWN_ERROR:
|
||||
// printf("epitar: error extracting tarball %s\n",
|
||||
// config.archive_file); ret_code = 3; break;
|
||||
|
||||
case BAD_CHECKSUM:
|
||||
puts("epitar: bad checksum");
|
||||
ret_code = 2;
|
||||
|
|
@ -33,17 +37,8 @@ static int handle_err_code(enum error_code err, struct config *config)
|
|||
__attribute__((fallthrough));
|
||||
|
||||
case EMPTY_ARCHIVE:
|
||||
if (config->mode == ARCHIVE)
|
||||
{
|
||||
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;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ static enum error_code archivefile(FILE *archive, char *file_path, bool verbose)
|
|||
FILE *file = fopen(file_path, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
printf("unable to add file %s", file_path);
|
||||
printf("Unable to add file %s", file_path);
|
||||
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)
|
||||
{
|
||||
// Does not exists
|
||||
printf("unable to add file %s", dir_path);
|
||||
printf("Unable to add file %s", dir_path);
|
||||
err = FILE_NOT_FOUND;
|
||||
}
|
||||
else if (isdir == SUCCESS)
|
||||
|
|
@ -204,7 +204,7 @@ enum error_code archive(char *archive_name, char **files, bool verbose)
|
|||
if (isdir == FILE_NOT_FOUND)
|
||||
{
|
||||
// Does not exists
|
||||
printf("unable to add file %s", *current_file);
|
||||
printf("Unable to add file %s", *current_file);
|
||||
err = FILE_NOT_FOUND;
|
||||
}
|
||||
else if (isdir == SUCCESS)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "../utils/filesystem.h"
|
||||
#include "tar.h"
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -136,12 +135,6 @@ enum error_code extract(char *archive_name, bool verbose)
|
|||
got_empty_block = false;
|
||||
}
|
||||
|
||||
if (!check_checksum(&header))
|
||||
{
|
||||
fclose(stream);
|
||||
return BAD_CHECKSUM;
|
||||
}
|
||||
|
||||
// Extract file
|
||||
enum error_code err = extract_file(stream, &header, verbose);
|
||||
if (err != SUCCESS)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ enum arg_error_code args_handler(int argc, char **argv, struct config *config)
|
|||
|
||||
// Parse option flags
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, ":cvxh")) != -1)
|
||||
while ((opt = getopt(argc, argv, "cxvh")) != -1)
|
||||
{
|
||||
int err = handle_opt(opt, config);
|
||||
if (err == ARG_HELP)
|
||||
|
|
|
|||
|
|
@ -282,23 +282,7 @@ echo -e "\n$BBlue=== Help and Invalid Arguments ===$Color_Off"
|
|||
test_help "Help flag"
|
||||
test_invalid_args "No arguments" ""
|
||||
test_invalid_args "Invalid flag" "-z"
|
||||
test_invalid_args "Invalid flagS" "-zbk"
|
||||
test_invalid_args "Invalid position" "test.tar -h"
|
||||
test_invalid_args "Invalid flags and position" "test.tar -z"
|
||||
test_invalid_args "Invalid flags and position mix" "test.tar -zhx"
|
||||
test_invalid_args "Invalid position" "test.tar -z"
|
||||
test_invalid_args "Invalid flag mix" "-zh"
|
||||
test_invalid_args "Invalid flag mix 2" "-hnh"
|
||||
test_invalid_args "Invalid flag mix 3" "-cnc"
|
||||
test_invalid_args "Invalid flag mix 3" "-hhhz"
|
||||
test_invalid_args "Invalid flag mix 3" "-hnc"
|
||||
test_invalid_args "Invalid flag mix 3" "-cch"
|
||||
test_invalid_args "Invalid flag mix 3" "-cnc"
|
||||
test_invalid_args "Valid flags multiple" "-cc"
|
||||
test_invalid_args "Incompatible flag" "-cx"
|
||||
test_invalid_args "Missing op flag" "-v"
|
||||
test_invalid_args "Missing archive (c)" "-c"
|
||||
test_invalid_args "Missing archive (x)" "-x"
|
||||
test_invalid_args "Missing archive" "-c"
|
||||
test_invalid_args "Extract with files" "-x archive.tar file.txt"
|
||||
|
||||
echo -e "\n$BBlue=== Edge Cases ===$Color_Off"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue