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.Unpack

Description

 
Synopsis

Documentation

unpack Source #

Arguments

:: Exception e 
=> FilePath

Base directory

-> Entries e

Entries to upack

-> IO () 

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 checkEntrySecurity). Use unpackAndCheck if you need more checks.

unpackAndCheck Source #

Arguments

:: Exception e 
=> (GenEntry FilePath FilePath -> Maybe SomeException)

Checks to run on each entry before unpacking

-> FilePath

Base directory

-> Entries e

Entries to upack

-> IO () 

Like unpack, but run custom sanity/security checks instead of checkEntrySecurity. For example,

unpackAndCheck (\x -> SomeException <$> checkEntryPortability x
                  <|> SomeException <$> checkEntrySecurity x) dir entries

Since: 0.6.0.0