stack-2.15.7: The Haskell Tool Stack
Safe HaskellSafe-Inferred
LanguageGHC2021

Codec.Archive.Tar.Utf8

Synopsis

Documentation

data Entry #

Instances

Instances details
Show Entry 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

showsPrec :: Int -> Entry -> ShowS

show :: Entry -> String #

showList :: [Entry] -> ShowS

NFData Entry 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

rnf :: Entry -> () #

Eq Entry 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

(==) :: Entry -> Entry -> Bool #

(/=) :: Entry -> Entry -> Bool #

data Entries e #

Constructors

Next Entry (Entries e) 
Done 
Fail e 

Instances

Instances details
Functor Entries 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

fmap :: (a -> b) -> Entries a -> Entries b #

(<$) :: a -> Entries b -> Entries a #

Monoid (Entries e) 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

mempty :: Entries e #

mappend :: Entries e -> Entries e -> Entries e #

mconcat :: [Entries e] -> Entries e #

Semigroup (Entries e) 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

(<>) :: Entries e -> Entries e -> Entries e #

sconcat :: NonEmpty (Entries e) -> Entries e

stimes :: Integral b => b -> Entries e -> Entries e

Show e => Show (Entries e) 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

showsPrec :: Int -> Entries e -> ShowS

show :: Entries e -> String #

showList :: [Entries e] -> ShowS

NFData e => NFData (Entries e) 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

rnf :: Entries e -> () #

Eq e => Eq (Entries e) 
Instance details

Defined in Codec.Archive.Tar.Types

Methods

(==) :: Entries e -> Entries e -> Bool #

(/=) :: Entries e -> Entries e -> Bool #

data EntryContent #

Constructors

NormalFile ByteString !FileSize 
Directory 
SymbolicLink !LinkTarget 
HardLink !LinkTarget 
CharacterDevice !DevMajor !DevMinor 
BlockDevice !DevMajor !DevMinor 
NamedPipe 
OtherEntryType !TypeCode ByteString !FileSize 

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') #

unfoldEntries :: (a -> Either e (Maybe (Entry, a))) -> a -> Entries e #

write :: [Entry] -> ByteString #

append :: FilePath -> FilePath -> [FilePath] -> IO () #

create :: FilePath -> FilePath -> [FilePath] -> IO () #

entryPath :: Entry -> FilePath Source #

Native FilePath of the file or directory within the archive.

Assumes that the TarPath of an Entry is UTF8 encoded.

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.