forked from Imagelibrary/rtems
RTEMS untar implementation had problems with overwriting or integrating archives into existing directory structures. This patch adapts the behavior to mimic that of a GNU tar or BSD tar and extends the tar01 test to check for the behavior. That is: * If a directory structure exists, the files from the archive will be integrated. Existing files are overwritten. * If a file exists and the archive contains a directory with the same name, the file is removed and a directory is created. In the above example: if l1/l2 is a file it will be overwritten with a new directory. * If a directory exists and the archive contains a file with the same name, the directory will be replaced if it is empty. If it contains files, the result is an error. * An archive also can contain only a file without the parent directories. If in that case one of the parent directories exists as a file extracting the archive results in an error. In the example: if l1/l2 is a file and the archive doesn't contain the directories but only the file l1/l2/x.txt that would be an error. * In case of an error, it is possible that the archive has been partially extracted. Closes #4568
#
#
# untar information
#
# Author: Jake Janovetz 7.6.1999
#
untar.c contains two procedures for extracting files from a UNIX
tar file:
int Untar_FromMemory(unsigned char *tar_buf, unsigned long size);
int Untar_FromFile(char *tar_name);
Untar_FromMemory(...) takes its input from a chunk of allocated memory.
This is particularly useful when the tar is stored in Flash memory or
comes from the FTP daemon by way of a hook.
Untar_FromFile(...) is identical except the source is from an existing
file. The fully qualified filename is passed through char *tar_name.
BUGS: Please email janovetz@uiuc.edu
-----