This project is to present a minimalistic, yet highly portable version of a program which extracts tar archives using only Ada standard package functionality.
Its key routine is the procedure Extract which unpacks an archive’s files. For this the archive is read in chunks of 512 bytes.
Every file in the archive is preceded by a header block. It contains the name, information on size and type of the adjacent data and a block checksum.
This minimalistic version of untar handles directories and regular files, but no special files like hard links, soft links, character devices, block devices and fifos. A data type indicating a directory causes this directory to be created.
If the data type indicates a regular file, one data chunk is read after the other and written to a newly created file until all data of this file has been extracted.
Drawing 1 shows this overall sequence of data extraction.
A detailed view of the header parsing is shown in Drawing 2.
Comments
Please log in or sign up to comment.