pack package:tar
Creates a tar archive from a list of directory or files. Any
directories specified will have their contents included recursively.
Paths in the archive will be relative to the given base directory.
This is a portable implementation of packing suitable for portable
archives. In particular it only constructs
NormalFile,
Directory and
SymbolicLink entries. Hard links are
treated like ordinary files. Special files like FIFOs (named pipes),
sockets or device files will cause problems.
- This function returns results lazily. Subdirectories are scanned
and files are read one by one as the list of entries is consumed. Do
not change their contents before the output of pack was
consumed in full.
Like
pack, but allows to specify additional sanity/security
checks on the input filenames. This is useful if you know which check
will be used on client side in
unpack /
unpackAndCheck.
Construct a tar entry based on a local directory (but not its
contents).
The only attribute of the directory that is used is its modification
time. Directory ownership and detailed permissions are not preserved.
Construct a tar entry based on a local file.
This sets the entry size, the data contained in the file and the
file's modification time. If the file is executable then that
information is also preserved. File ownership and detailed permissions
are not preserved.
- The file contents is read lazily.
Construct a tar entry based on a local symlink.
Create local files and directories based on the entries of a tar
archive.
This is a portable implementation of unpacking suitable for portable
archives. It handles
NormalFile and
Directory entries
and has simulated support for
SymbolicLink and
HardLink
entries. Links are implemented by copying the target file. This
therefore works on Windows as well as Unix. All other entry types are
ignored, that is they are not unpacked and no exception is raised.
If the
Entries ends in an error then it is raised an an
exception. Any files or directories that have been unpacked before the
error was encountered will not be deleted. For this reason you may
want to unpack into an empty directory so that you can easily clean up
if unpacking fails part-way.
On its own, this function only checks for security (using
checkEntrySecurity). Use
unpackAndCheck if you need more
checks.
Like
unpack, but run custom sanity/security checks instead of
checkEntrySecurity. For example,
import Control.Exception (SomeException(..))
import Control.Applicative ((<|>))
unpackAndCheck (\x -> SomeException <$> checkEntryPortability x
<|> SomeException <$> checkEntrySecurity x) dir entries