tar-0.1.1.1: TAR (tape archive format) library.

Codec.Archive.Tar

Contents

Description

This is a library for reading and writing TAR archives.

Synopsis

TAR archive types

newtype TarArchive Source

A TAR archive.

Constructors

TarArchive 

Instances

data TarEntry Source

A TAR archive entry for a file or directory.

Constructors

TarEntry 

Fields

entryHeader :: TarHeader

Entry meta-data.

entryData :: ByteString

Entry contents. For entries other than normal files, this should be an empty string.

Instances

data TarHeader Source

TAR archive entry meta-data.

Constructors

TarHeader 

Fields

tarFileName :: FilePath

Path of the file or directory. The path separator should be / for portable TAR archives.

tarFileMode :: FileMode

UNIX file mode.

tarOwnerID :: UserID

Numeric owner user id. Should be set to 0 if unknown.

tarGroupID :: GroupID

Numeric owner group id. Should be set to 0 if unknown.

tarFileSize :: Int64

File size in bytes. Should be 0 for entries other than normal files.

tarModTime :: EpochTime

Last modification time, expressed as the number of seconds since the UNIX epoch.

tarFileType :: TarFileType

Type of this entry.

tarLinkTarget :: FilePath

If the entry is a hard link or a symbolic link, this is the path of the link target. For all other entry types this should be "".

tarOwnerName :: String

The owner user name. Should be set to "" if unknown.

tarGroupName :: String

The owner group name. Should be set to "" if unknown.

tarDeviceMajor :: CMajor

For character and block device entries, this is the major number of the device. For all other entry types, it should be set to 0.

tarDeviceMinor :: CMinor

For character and block device entries, this is the minor number of the device. For all other entry types, it should be set to 0.

Instances

Creating TAR archives

createTarFileSource

Arguments

:: FilePath

File to write the archive to.

-> [FilePath]

Files and directories to include in the archive.

-> IO () 

Creates a TAR archive containing a number of files and directories, and write the archive to a file.

See createTarArchive and writeTarArchive for more information.

createTarDataSource

Arguments

:: [FilePath]

Files and directories to include in the archive.

-> IO ByteString 

Creates a TAR archive containing a number of files and directories, and returns the archive as a lazy ByteString.

See createTarArchive and writeTarArchive for more information.

createTarArchiveSource

Arguments

:: [FilePath]

Files and directories to include in the archive.

-> IO TarArchive 

Creates a TAR archive containing a number of files and directories taken from the file system. In the list of paths, any directory should come before any files in that directory. Only files and directories mentioned in the list are included, this function does not recurse into the directories.

createTarEntry :: FilePath -> IO TarEntrySource

Creates a TAR archive entry for a file or directory. The meta-data and file contents are taken from the given file.

recurseDirectories :: [FilePath] -> IO [FilePath]Source

Recurses through a list of files and directories in depth-first order. Each of the given paths are returned, and each path which refers to a directory is followed by its descendants. The output is suitable for feeding to the TAR archive creation functions.

Writing TAR archives

writeTarArchive :: TarArchive -> ByteStringSource

Writes a TAR archive to a lazy ByteString.

The archive is written in USTAR (POSIX.1-1988) format (tar with extended header information).

writeTarFileSource

Arguments

:: FilePath

The file to write the archive to.

-> TarArchive

The archive to write out.

-> IO () 

Writes a TAR archive to a file.

See writeTarArchive for more information.

Extracting TAR archives

extractTarFileSource

Arguments

:: FilePath

File from which the archive is read.

-> IO () 

Reads a TAR archive from a file and extracts its contents into the current directory.

See readTarArchive and extractTarArchive for more information.

extractTarDataSource

Arguments

:: ByteString

Data from which the archive is read.

-> IO () 

Reads a TAR archive from a lazy ByteString and extracts its contents into the current directory.

See readTarArchive and extractTarArchive for more information.

extractTarArchive :: TarArchive -> IO ()Source

Extracts the contents of a TAR archive into the current directory.

If problems are encountered, warnings are printed to stderr, and the extraction continues.

extractTarEntry :: TarEntry -> IO ()Source

Extracts a TAR entry into the current directory.

This function throws an exception if any problems are encountered.

Reading TAR archives

readTarArchive :: ByteString -> TarArchiveSource

Reads a TAR archive from a lazy ByteString.

readTarFileSource

Arguments

:: FilePath

File to read the archive from.

-> IO TarArchive 

Reads a TAR archive from a file.

See readTarArchive for more information.