From a5d9db51af59760a577f781463e8466d05f4ade9 Mon Sep 17 00:00:00 2001 From: Nick Westgate Date: Tue, 10 Apr 2018 22:32:39 +1200 Subject: [PATCH 1/4] Merge pull request #18 from sicklittlemonkey/master (#1) From 3eee954bd7fbc770f0d4081f85e0013864d5f3e7 Mon Sep 17 00:00:00 2001 From: Nick Westgate Date: Tue, 10 Apr 2018 22:36:21 +1200 Subject: [PATCH 2/4] Return some error codes - AddFile in ADDFILE - AddFile in REPLACEFILE - Set/ClearFileHighBit first error (untested!) - In/OutdentFile first error (untested!) --- Src/Main.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Src/Main.c b/Src/Main.c index 87486f6..33ad492 100644 --- a/Src/Main.c +++ b/Src/Main.c @@ -104,6 +104,8 @@ int main(int argc, char *argv[]) return(2); param->verbose = verbose; + int exit_code = 0; + /** Actions **/ if(param->action == ACTION_CATALOG) { @@ -381,7 +383,7 @@ int main(int argc, char *argv[]) printf(" - Add file '%s' :\n",param->file_path); /** Ajoute le fichier dans l'archive **/ - AddFile(current_image,param->file_path,param->prodos_folder_path,1); + exit_code = AddFile(current_image,param->file_path,param->prodos_folder_path,1); /* Libération mémoire */ mem_free_image(current_image); @@ -436,7 +438,7 @@ int main(int argc, char *argv[]) printf(" - Replacing file '%s' :\n",prodos_file_name); DeleteProdosFile(current_image, prodos_file_name); - AddFile(current_image, param->file_path, param->prodos_folder_path,1); + exit_code = AddFile(current_image, param->file_path, param->prodos_folder_path,1); free(prodos_file_name); mem_free_image(current_image); @@ -450,7 +452,9 @@ int main(int argc, char *argv[]) for(i=0; i Date: Thu, 12 Apr 2018 08:09:04 +1200 Subject: [PATCH 3/4] Error codes for EXTRACTFILE Returns any error from ExtractOneFile. --- Src/Main.c | 2 +- Src/Prodos_Extract.c | 11 +++++++---- Src/Prodos_Extract.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Src/Main.c b/Src/Main.c index 33ad492..2bf3680 100644 --- a/Src/Main.c +++ b/Src/Main.c @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) return(3); /** Extrait le fichier sur disque **/ - ExtractOneFile( + exit_code = ExtractOneFile( current_image, param->prodos_file_path, param->output_directory_path, diff --git a/Src/Prodos_Extract.c b/Src/Prodos_Extract.c index cec6efa..c297a03 100644 --- a/Src/Prodos_Extract.c +++ b/Src/Prodos_Extract.c @@ -33,7 +33,7 @@ static void SetFileInformation(char *,struct prodos_file *); * @param output_directory_path * @param output_apple_single */ -void ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, char *output_directory_path, bool output_apple_single) +int ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, char *output_directory_path, bool output_apple_single) { int error; struct file_descriptive_entry *current_entry; @@ -42,14 +42,14 @@ void ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, /** Recherche l'entrée du fichier **/ current_entry = GetProdosFile(current_image,prodos_file_path); if(current_entry == NULL) - return; + return(1); /** Allocation mémoire **/ current_file = (struct prodos_file *) calloc(1,sizeof(struct prodos_file)); if(current_file == NULL) { printf(" Error : Can't get file from Image : Memory Allocation impossible.\n"); - return; + return(1); } current_file->entry = current_entry; @@ -58,8 +58,9 @@ void ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, if(error) { printf(" Error : Can't get file from Image : Memory Allocation impossible.\n"); + current_image->nb_extract_error++; mem_free_file(current_file); - return; + return(1); } /** Création du fichier sur disque **/ @@ -67,6 +68,8 @@ void ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, /* Libération mémoire */ mem_free_file(current_file); + + return (error); } diff --git a/Src/Prodos_Extract.h b/Src/Prodos_Extract.h index 883d9ba..df6eb4c 100644 --- a/Src/Prodos_Extract.h +++ b/Src/Prodos_Extract.h @@ -8,7 +8,7 @@ #include -void ExtractOneFile(struct prodos_image *, char *, char *, bool); +int ExtractOneFile(struct prodos_image *, char *, char *, bool); void ExtractFolderFiles(struct prodos_image *, struct file_descriptive_entry *, char *, bool); void ExtractVolumeFiles(struct prodos_image *, char *, bool); From b0845a73ff529fb62aa8451e8131b665211925c5 Mon Sep 17 00:00:00 2001 From: Nick Westgate Date: Thu, 12 Apr 2018 08:13:41 +1200 Subject: [PATCH 4/4] Return correct error Better to pass up the error from called functions. --- Src/Prodos_Extract.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Prodos_Extract.c b/Src/Prodos_Extract.c index c297a03..30cd59d 100644 --- a/Src/Prodos_Extract.c +++ b/Src/Prodos_Extract.c @@ -60,7 +60,7 @@ int ExtractOneFile(struct prodos_image *current_image, char *prodos_file_path, c printf(" Error : Can't get file from Image : Memory Allocation impossible.\n"); current_image->nb_extract_error++; mem_free_file(current_file); - return(1); + return(error); } /** Création du fichier sur disque **/