tar-0.6.0.0: Reading, writing and manipulating ".tar" archive files.
Copyright(c) 2007 Bjorn Bringert
2008 Andrea Vezzosi
2008-2009 2012 2016 Duncan Coutts
LicenseBSD3
Maintainerduncan@community.haskell.org
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Codec.Archive.Tar.Pack

Description

 
Synopsis

Documentation

pack Source #

Arguments

:: FilePath

Base directory

-> [FilePath]

Files and directories to pack, relative to the base dir

-> IO [Entry] 

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.

An exception will be thrown for any file names that are too long to represent as a TarPath.

  • This function returns results lazily. Subdirectories are scanned and files are read one by one as the list of entries is consumed.

packAndCheck Source #

Arguments

:: (GenEntry FilePath FilePath -> Maybe SomeException) 
-> FilePath

Base directory

-> [FilePath]

Files and directories to pack, relative to the base dir

-> IO [Entry] 

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.

Since: 0.6.0.0

packFileEntry Source #

Arguments

:: FilePath

Full path to find the file on the local disk

-> tarPath

Path to use for the tar GenEntry in the archive

-> IO (GenEntry tarPath linkTarget) 

Construct a tar GenEntry 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.

packDirectoryEntry Source #

Arguments

:: FilePath

Full path to find the file on the local disk

-> tarPath

Path to use for the tar GenEntry in the archive

-> IO (GenEntry tarPath linkTarget) 

Construct a tar GenEntry 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.

packSymlinkEntry Source #

Arguments

:: FilePath

Full path to find the file on the local disk

-> tarPath

Path to use for the tar GenEntry in the archive

-> IO (GenEntry tarPath FilePath) 

Construct a tar GenEntry based on a local symlink.

This automatically checks symlink safety via checkEntrySecurity.

Since: 0.6.0.0

longLinkEntry :: FilePath -> GenEntry TarPath linkTarget Source #

GNU extension to store a filepath too long to fit into entryTarPath as OtherEntryType 'L' with the full filepath as entryContent. The next entry must contain the actual data with truncated entryTarPath.

See What exactly is the GNU tar ..@LongLink "trick"?

Since: 0.6.0.0

getDirectoryContentsRecursive :: FilePath -> IO [FilePath] Source #

This is a utility function, much like listDirectory. The difference is that it includes the contents of subdirectories.

The paths returned are all relative to the top directory. Directory paths are distinguishable by having a trailing path separator (see hasTrailingPathSeparator).

All directories are listed before the files that they contain. Amongst the contents of a directory, subdirectories are listed after normal files. The overall result is that files within a directory will be together in a single contiguous group. This tends to improve file layout and IO performance when creating or extracting tar archives.

  • This function returns results lazily. Subdirectories are not scanned until the files entries in the parent directory have been consumed. If the source directory structure changes before the result is used, the behaviour is undefined.