You should know the size of the element/file you are going to add to the archive. Using that you can calculate where the file is inside the archive.

e.g. if the header size is 10 bytes. file1 is 100 bytes and file3 is 120 bytes you can add a file at 10+100+120 or put the list of files with sizes there.

Also if you want to read the second file you know it is at 10+100.

Also in the header you should store the total size of files so you know where the file list is (FILE_RECORD).

folders/directories are easy as they are not existing files. Enumerate them and you can refer them in the file record.

example of possible file record (id, name, size, folderid)
1 file1 100 3
2 file2 120 3
3 folder1 0
4 folder2 3