I am creating a file archiver/extractor(like tar), using POSIX API system calls in C. I have done part of the archiving bit.
I would like to know if any one could help me with some C source code(using above) to create a file header for a file in C(where header acts as an index not a header file), which describes the files attributes/meta data(name,date time,etc).All I have done so far is understand(not sure if thats even correct) that to create a header file it needs
a struct to hold the meta data, and lseek is needed to seek to beginning/end of file
The archiving part of program has this process:
1. Get a list of all the files from the command line.( I can do this part)
2. Create a structure to hold the meta data about each file: name (255 char), size (64-bit int), date and time, and permissions.
3. For each file, get its stats.
4. Store the stats of each file within an array of structures.
5. Open the archive for writing.( I can do this part)
6. Write the header structure.
7. For each file, append its content to the archive file.(at the end/start of each file).
8. Close the archive file.( I can do this part)
I am having difficulty in creating the header file as a whole even though I know what it needs to do, as mentioned in numbered points above the bits I cant do are stated.(2,3,4,6,7).
Any help will be appreciated.
Edited 6 Years Ago by Don_k: wrong way round