I am writing a C program that basically creates an archive file for a given list of file names. This is very similar to the ar command on Linux. Here's what the archive file would look like:
!<arch> file1.txt/ 1350248044 45503 13036 100660 28 ` hello this is sample file 1 file2.txt/ 1350512270 45503 13036 100660 72 ` hello this is sample file 2 this file is a little larger than file1.txt
But I am having difficulty extracting the file from the archive. Say the user wants to extract file1.txt . The idea is that it should have an index / location of the file name (in this case file1.txt), skip 58 characters to reach the contents of the file, read the content and write it to a new file. So here are my questions:
1) How can I get the index / location of the file name in the archive? Please note that duplicate file names are NOT allowed, so I donβt have to worry about having two different indexes.
2) How to skip a few characters (in this case 58) when reading a file?
3) How can I understand when the contents of a file end? that is, I need it to read the contents and stop right in front of the file2.txt/ header.
PoweredByOrange
source share