I'm trying to create a basic version of the linux "tar" command using C, i used perror to see if there are any errors during execution, and i got this
./tar
Error2: Bad file descriptor
and this is what i did so far
#include <stdio.h>
#include <libtar.h>
#include <fcntl.h>
int main(void)
{
TAR *pTar;
char *prefix = ".";
char *filename = "file.tar";
if ((tar_open(&pTar, filename, NULL, O_WRONLY, 0644, TAR_GNU)) == -1)
perror("Error1");
else if ((tar_extract_all(pTar, prefix)) == -1)
perror("Error2");
else if ((tar_close(pTar)) == -1)
perror("Error3");
}
Thanks in advance:)