tar-0.1.1: TAR (tape archive format) library.Source codeContentsIndex
Codec.Archive.Tar
Contents
TAR archive types
Creating TAR archives
Writing TAR archives
Extracting TAR archives
Reading TAR archives
Description
This is a library for reading and writing TAR archives.
Synopsis
newtype TarArchive = TarArchive {
archiveEntries :: [TarEntry]
}
data TarEntry = TarEntry {
entryHeader :: TarHeader
entryData :: ByteString
}
data TarHeader = TarHeader {
tarFileName :: FilePath
tarFileMode :: FileMode
tarOwnerID :: UserID
tarGroupID :: GroupID
tarFileSize :: Int64
tarModTime :: EpochTime
tarFileType :: TarFileType
tarLinkTarget :: FilePath
tarOwnerName :: String
tarGroupName :: String
tarDeviceMajor :: CMajor
tarDeviceMinor :: CMinor
}
data TarFileType
= TarNormalFile
| TarHardLink
| TarSymbolicLink
| TarCharacterDevice
| TarBlockDevice
| TarDirectory
| TarFIFO
| TarOther Char
createTarFile :: FilePath -> [FilePath] -> IO ()
createTarData :: [FilePath] -> IO ByteString
createTarArchive :: [FilePath] -> IO TarArchive
createTarEntry :: FilePath -> IO TarEntry
recurseDirectories :: [FilePath] -> IO [FilePath]
writeTarArchive :: TarArchive -> ByteString
writeTarFile :: FilePath -> TarArchive -> IO ()
extractTarFile :: FilePath -> IO ()
extractTarData :: ByteString -> IO ()
extractTarArchive :: TarArchive -> IO ()
extractTarEntry :: TarEntry -> IO ()
readTarArchive :: ByteString -> TarArchive
readTarFile :: FilePath -> IO TarArchive
TAR archive types
newtype TarArchive Source
A TAR archive.
Constructors
TarArchive
archiveEntries :: [TarEntry]
show/hide Instances
data TarEntry Source
A TAR archive entry for a file or directory.
Constructors
TarEntry
entryHeader :: TarHeaderEntry meta-data.
entryData :: ByteStringEntry contents. For entries other than normal files, this should be an empty string.
show/hide Instances
data TarHeader Source
TAR archive entry meta-data.
Constructors
TarHeader
tarFileName :: FilePathPath of the file or directory. The path separator should be / for portable TAR archives.
tarFileMode :: FileModeUNIX file mode.
tarOwnerID :: UserIDNumeric owner user id. Should be set to 0 if unknown.
tarGroupID :: GroupIDNumeric owner group id. Should be set to 0 if unknown.
tarFileSize :: Int64File size in bytes. Should be 0 for entries other than normal files.
tarModTime :: EpochTimeLast modification time, expressed as the number of seconds since the UNIX epoch.
tarFileType :: TarFileTypeType of this entry.
tarLinkTarget :: FilePathIf 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 :: StringThe owner user name. Should be set to "" if unknown.
tarGroupName :: StringThe owner group name. Should be set to "" if unknown.
tarDeviceMajor :: CMajorFor 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 :: CMinorFor character and block device entries, this is the minor number of the device. For all other entry types, it should be set to 0.
show/hide Instances
data TarFileType Source
TAR archive entry types.
Constructors
TarNormalFile
TarHardLink
TarSymbolicLink
TarCharacterDevice
TarBlockDevice
TarDirectory
TarFIFO
TarOther Char
show/hide Instances
Creating TAR archives
createTarFileSource
:: FilePathFile 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
:: [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
:: [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
:: FilePathThe file to write the archive to.
-> TarArchiveThe archive to write out.
-> IO ()

Writes a TAR archive to a file.

See writeTarArchive for more information.

Extracting TAR archives
extractTarFileSource
:: FilePathFile 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
:: ByteStringData 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
:: FilePathFile to read the archive from.
-> IO TarArchive

Reads a TAR archive from a file.

See readTarArchive for more information.

Produced by Haddock version 2.1.0