Skip to content
Snippets Groups Projects
Commit fe3fca6c authored by Thierno souleymane Bah's avatar Thierno souleymane Bah
Browse files

fix(remove volume improved, we can now delete a specific volume)

parent f7e1fd7d
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,14 @@ int main(int argc, char const *argv[])
/* Allows all IT */
_mask(1);
if (argc != 2)
{
fprintf(stderr, "Usage: %s <volume> \n", argv[0]);
exit(EXIT_FAILURE);
}
load_mbr();
remove_vol();
remove_vol(atoi(argv[1]));
save_mbr();
/* and exit! */
......
......@@ -146,12 +146,16 @@ void display_vols()
}
}
void remove_vol()
void remove_vol(int vol)
{
if (mbr.nb_vols == 0)
int i;
if (vol >= mbr.nb_vols)
{
fprintf(stderr, "Vous ne disposez d'aucun volume \n");
fprintf(stderr, "Ce volume n'existe pas. \n");
return;
}
for (i = vol; i < mbr.nb_vols - 1; i++)
mbr.vols[i] = mbr.vols[i + 1];
mbr.nb_vols--;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment