Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions Src/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -149,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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -450,7 +452,9 @@ int main(int argc, char *argv[])
for(i=0; i<nb_filepath; i++)
{
printf(" - Clear High bit for file '%s'\n",filepath_tab[i]);
ClearFileHighBit(filepath_tab[i]);
int result = ClearFileHighBit(filepath_tab[i]);
if (!exit_code && result)
exit_code = result;
}

/* Libération mémoire */
Expand All @@ -465,8 +469,10 @@ int main(int argc, char *argv[])
for(i=0; i<nb_filepath; i++)
{
printf(" - Set High bit for file '%s'\n",filepath_tab[i]);
SetFileHighBit(filepath_tab[i]);
}
int result = SetFileHighBit(filepath_tab[i]);
if (!exit_code && result)
exit_code = result;
}

/* Libération mémoire */
mem_free_list(nb_filepath,filepath_tab);
Expand All @@ -480,8 +486,10 @@ int main(int argc, char *argv[])
for(i=0; i<nb_filepath; i++)
{
printf(" - Indent file '%s'\n",filepath_tab[i]);
IndentFile(filepath_tab[i]);
}
int result = IndentFile(filepath_tab[i]);
if (!exit_code && result)
exit_code = result;
}

/* Libération mémoire */
mem_free_list(nb_filepath,filepath_tab);
Expand All @@ -495,8 +503,10 @@ int main(int argc, char *argv[])
for(i=0; i<nb_filepath; i++)
{
printf(" - Outdent file '%s'\n",filepath_tab[i]);
OutdentFile(filepath_tab[i]);
}
int result = OutdentFile(filepath_tab[i]);
if (!exit_code && result)
exit_code = result;
}

/* Libération mémoire */
mem_free_list(nb_filepath,filepath_tab);
Expand All @@ -507,7 +517,7 @@ int main(int argc, char *argv[])
my_Memory(MEMORY_FREE,NULL,NULL);

/* OK */
return(0);
return(exit_code);
}


Expand Down
11 changes: 7 additions & 4 deletions Src/Prodos_Extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -58,15 +58,18 @@ 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(error);
}

/** Création du fichier sur disque **/
error = CreateOutputFile(current_file,output_directory_path,output_apple_single);

/* Libération mémoire */
mem_free_file(current_file);

return (error);
}


Expand Down
2 changes: 1 addition & 1 deletion Src/Prodos_Extract.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <stdbool.h>

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);

Expand Down