archiveutil

package
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrValidation = &Error{Kind: KindValidation}
	ErrIntegrity  = &Error{Kind: KindIntegrity}
	ErrTransport  = &Error{Kind: KindTransport}
)

Functions

func SecureJoinArchivePath

func SecureJoinArchivePath(destRoot, entryName string) (string, error)

func TarGzDir

func TarGzDir(fsDir, prefixPath string) ([]byte, error)

func TarGzDirFiles

func TarGzDirFiles(fsDir, prefixPath string, skipNames map[string]struct{}) ([]byte, error)

TarGzDirFiles creates a gzip-compressed tar of only the regular files and symlinks immediately inside fsDir (no subdirectory recursion). Files whose base names match skipNames are excluded. Returns nil if there are no files to include.

func TarGzDirFilesTo

func TarGzDirFilesTo(w io.Writer, fsDir, prefixPath string, skipNames map[string]struct{}) (bool, error)

TarGzDirFilesTo writes a gzip-compressed tar of only the regular files immediately inside fsDir into w. Returns (hasFiles bool, err error). hasFiles is false if there are no files to write (nothing was written to w).

func TarGzDirTo

func TarGzDirTo(w io.Writer, fsDir, prefixPath string) error

TarGzDirTo writes a gzip-compressed tar of fsDir into w. prefixPath is used as the tar name prefix (same semantics as TarGzDir).

func UntarGzDir

func UntarGzDir(gzipStream io.Reader, dest string) error

func UntarGzDirRootFilesOnly

func UntarGzDirRootFilesOnly(gzipStream io.Reader, dest, requiredPrefix string) error

UntarGzDirRootFilesOnly extracts a gzip-compressed tar into dest. Only the directory entry for requiredPrefix itself, and regular files directly under requiredPrefix (no subdirectories), are allowed. Entries that go deeper return ErrIntegrity.

func UntarGzDirUnderPrefix

func UntarGzDirUnderPrefix(gzipStream io.Reader, dest, requiredPrefix string) error

UntarGzDirUnderPrefix extracts a gzip-compressed tar into dest. Every tar entry's path must begin with requiredPrefix+"/" or be exactly requiredPrefix. Entries outside that prefix return ErrIntegrity.

Types

type Error

type Error struct {
	Kind    ErrorKind
	Op      string
	Message string
	Err     error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string
const (
	KindValidation ErrorKind = "validation"
	KindIntegrity  ErrorKind = "integrity"
	KindTransport  ErrorKind = "transport"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL