Greetings Stackoverflow,
I have a project where I will need to write a C program which generates a .tar archive using files that are specified in the command line arguments. The program is supposed to simulate and work just like the built in tar function of Linux. The program should be run from the command line much in the same way as the default tar function.
Command to Create a tar from three files in args: ./tar c archive.tar file1 file2 file3
It also has to be able to unpack tar archives and restore the included files, along with their permissions, access time, and modification time.
Command to unpack a .tar file: ./tar x archive.tar
I cannot use the system() function in order to call tar() from inside my script. Instead have to use the built in Linux system calls.
Also for each file and directory to be included in the archive, the permissions must be retained, also the modification time, and the access time. I'm assuming this can be done by calling stat() for each file and then checking the struct stat members.
How should I go about doing this?
Having a lot of trouble with this project...