I am stuck on my C program which allows users to add files into an output (archive) file and also extract them all back out, ie so user can back up files on his system.
My program has two main commands one which allows user to specify files to add and the other to extract all files added.
I am unsure on a few concepts. I can get the users input of the files to add using 'argv' array. I can 'open()' each file specified, 'read()' the contents and 'write()' to an output archive file specified by user.
The issues I am stuck on is:
) Obviously the file size of files user wants to add will vary and the so will the type ie(.txt,.gif etc - thus I got variable 'char buffer[BUFSIZ]; ' used from <stdlib.h> instead of setting a defined value like buffer[?]
) using the 'read()' function, I am using the returned value of bytes read from there inside my 'write()' function, to copy the contents of that file into the output archive file (effectively adding files into this archive output file)
Problem is - How can I structure each file added into the archive folder, so I can easily extract them?
For example, I understand write() will write all files as binary, long string of bytes (0 & 1s) , inside this one output file. So how can I extract each file, using correct number of bytes and filenames, so they extract out back as individual original files when added?
Code is to long at this moment to add here, but hope some can give any ideas?