Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Codec.Archive.Tar.Utf8
Synopsis
- data Entry
- data Entries e
- data FormatError
- data EntryContent
- = NormalFile ByteString !FileSize
- | Directory
- | SymbolicLink !LinkTarget
- | HardLink !LinkTarget
- | CharacterDevice !DevMajor !DevMinor
- | BlockDevice !DevMajor !DevMinor
- | NamedPipe
- | OtherEntryType !TypeCode ByteString !FileSize
- pack :: FilePath -> [FilePath] -> IO [Entry]
- read :: ByteString -> Entries FormatError
- foldEntries :: (Entry -> a -> a) -> a -> (e -> a) -> Entries e -> a
- foldlEntries :: (a -> Entry -> a) -> a -> Entries e -> Either (e, a) a
- mapEntries :: (Entry -> Either e' Entry) -> Entries e -> Entries (Either e e')
- mapEntriesNoFail :: (Entry -> Entry) -> Entries e -> Entries e
- unfoldEntries :: (a -> Either e (Maybe (Entry, a))) -> a -> Entries e
- write :: [Entry] -> ByteString
- append :: FilePath -> FilePath -> [FilePath] -> IO ()
- create :: FilePath -> FilePath -> [FilePath] -> IO ()
- extract :: FilePath -> FilePath -> IO ()
- entryPath :: Entry -> FilePath
- unpack :: Exception e => FilePath -> Entries e -> IO ()
Documentation
data FormatError #
Constructors
TruncatedArchive | |
ShortTrailer | |
BadTrailer | |
TrailingJunk | |
ChecksumIncorrect | |
NotTarFormat | |
UnrecognisedTarFormat | |
HeaderBadNumericEncoding |
Instances
Exception FormatError | |
Defined in Codec.Archive.Tar.Read Methods toException :: FormatError -> SomeException # fromException :: SomeException -> Maybe FormatError # displayException :: FormatError -> String # | |
Show FormatError | |
Defined in Codec.Archive.Tar.Read Methods showsPrec :: Int -> FormatError -> ShowS show :: FormatError -> String # showList :: [FormatError] -> ShowS | |
NFData FormatError | |
Defined in Codec.Archive.Tar.Read Methods rnf :: FormatError -> () # | |
Eq FormatError | |
Defined in Codec.Archive.Tar.Read |
data EntryContent #
Constructors
NormalFile ByteString !FileSize | |
Directory | |
SymbolicLink !LinkTarget | |
HardLink !LinkTarget | |
CharacterDevice !DevMajor !DevMinor | |
BlockDevice !DevMajor !DevMinor | |
NamedPipe | |
OtherEntryType !TypeCode ByteString !FileSize |
Instances
Show EntryContent | |
Defined in Codec.Archive.Tar.Types Methods showsPrec :: Int -> EntryContent -> ShowS show :: EntryContent -> String # showList :: [EntryContent] -> ShowS | |
NFData EntryContent | |
Defined in Codec.Archive.Tar.Types Methods rnf :: EntryContent -> () # | |
Eq EntryContent | |
Defined in Codec.Archive.Tar.Types | |
Ord EntryContent | |
Defined in Codec.Archive.Tar.Types Methods compare :: EntryContent -> EntryContent -> Ordering # (<) :: EntryContent -> EntryContent -> Bool # (<=) :: EntryContent -> EntryContent -> Bool # (>) :: EntryContent -> EntryContent -> Bool # (>=) :: EntryContent -> EntryContent -> Bool # max :: EntryContent -> EntryContent -> EntryContent # min :: EntryContent -> EntryContent -> EntryContent # |
read :: ByteString -> Entries FormatError #
foldEntries :: (Entry -> a -> a) -> a -> (e -> a) -> Entries e -> a #
foldlEntries :: (a -> Entry -> a) -> a -> Entries e -> Either (e, a) a #
unpack :: Exception e => FilePath -> Entries e -> IO () Source #
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 checkSecurity
).
You can do other checks by applying checking functions to the Entries
that
you pass to this function. For example:
unpack dir (checkTarbomb expectedDir entries)
If you care about the priority of the reported errors then you may want to
use checkSecurity
before checkTarbomb
or other checks.
Assumes that the TarPath
of an Entry
is UTF8 encoded.