Documentation
¶
Index ¶
- Variables
- func CreateTarGz(base, rootDir, baseDir string) (string, error)
- func Extract(r io.Reader, dest string, o ExtractOptions) error
- func ExtractTarGz(archive, dest string) error
- func MemberNames(r io.Reader) ([]string, error)
- func MemberParts(name string) ([]string, error)
- func RootDirs(archive string) (map[string]bool, error)
- type Adder
- type ExtractOptions
- type MemberError
Constants ¶
This section is empty.
Variables ¶
var ErrOutsideDest = errors.New("member leads outside the destination")
Member that would land, or link, outside the extraction directory
var ErrTooLarge = errors.New("member does not fit in the space left on the destination")
Member whose content would not fit in the space left on the destination's volume, the guard against decompression bombs
var ErrUnsafePath = errors.New("unsafe member path")
Member name that is empty, absolute, on a drive or share, or climbing out through a dot-dot element
var ErrUnsupportedType = errors.New("unsupported member type")
Member of a kind extraction does not create: a device, a fifo, or a link where links are refused
Functions ¶
func CreateTarGz ¶
Writes base.tar.gz in GNU format holding the tree at rootDir/baseDir under the name baseDir, entries in sorted order, symbolic links stored as links and every hard link as a file of its own, through a temp file beside it that is flushed and renamed into place once complete and removed on any failure or panic; gives back the archive path
func Extract ¶
func Extract(r io.Reader, dest string, o ExtractOptions) error
Extracts a tar stream below dest, made when missing: directories, regular files with owner read and write added and no setuid, setgid or write bits for others, owner execute deciding execute for all, and links when allowed; every name must pass MemberParts and resolve inside dest, a link's target too, judged where the system will follow it, a refused member stopping the extraction with a *MemberError; content that would not fit in the space left on dest's volume is refused with ErrTooLarge before it is written; modification times are restored, directories' last
func ExtractTarGz ¶
Extracts the gzip compressed tar file at archive below dest like Extract with links refused, so only directories and regular files come out
func MemberNames ¶
Names of the members of a tar stream in stream order, a directory's trailing slash dropped
func MemberParts ¶
Relative path elements of an archive member name split at / and \, empty and . elements dropped; a name that is empty, absolute, on a drive or share, has no element left or holds a .. element fails with a *MemberError wrapping ErrUnsafePath
Types ¶
type Adder ¶
type Adder struct {
W *tar.Writer
Format tar.Format
FlattenHardLinks bool
// contains filtered or unexported fields
}
Writer of files and trees into the tar stream W, directories in sorted order and symbolic links stored unfollowed; a file met again through another hard link becomes a link member naming the member it was first written as, unless FlattenHardLinks stores its content again, and a non-zero Format is set on every header
func (*Adder) Add ¶
Adds the file or directory at path as the member name, a directory's entries below it too when recursive; filter may change each header, or drop the member and a dropped directory's entries by giving back nil; sockets, fifos and devices are skipped, carrying no content and being refused by every extraction here
type ExtractOptions ¶
type ExtractOptions struct {
Links bool
}
Settings of Extract: Links extracts symbolic and hard links that resolve inside the destination, refusing them with ErrUnsupportedType when false
type MemberError ¶
Archive member refused by its name, kind or size, wrapping ErrUnsafePath, ErrOutsideDest, ErrUnsupportedType or ErrTooLarge
func (*MemberError) Error ¶
func (e *MemberError) Error() string
The member and the reason, as in archive member "../x": unsafe member path