copyutil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTar

func ExtractTar(r io.Reader, dest string) error

ExtractTar extracts a tar archive stream into dest. It rejects absolute or parent-traversal paths.

func ExtractTarWithOptions

func ExtractTarWithOptions(r io.Reader, dest string, opts ExtractOptions) error

ExtractTarWithOptions extracts a tar archive stream into dest with optional callbacks.

func MoveTree

func MoveTree(src, dst string) error

MoveTree moves src into dst, merging into dst when it already exists. It attempts to use renames for atomic moves where possible.

func ReadHeader

func ReadHeader(r *bufio.Reader) (string, string, error)

ReadHeader reads a copy stream header and returns kind and base name.

func TarDirectory

func TarDirectory(w io.Writer, src string, prefix string) error

TarDirectory writes a tar archive of src into w. Entries are relative to src, with an optional prefix applied.

func TarDirectoryWithObserver

func TarDirectoryWithObserver(w io.Writer, src string, prefix string, observer TarObserver) error

TarDirectoryWithObserver writes a tar archive of src into w, invoking observer for each entry.

func TarFile

func TarFile(w io.Writer, src string, name string) error

TarFile writes a single file or symlink entry to w with the provided name.

func TarFileWithObserver

func TarFileWithObserver(w io.Writer, src string, name string, observer TarObserver) error

TarFileWithObserver writes a single file or symlink entry to w, invoking observer.

func WriteHeader

func WriteHeader(w io.Writer, kind, base string) error

WriteHeader writes a copy stream header that precedes payload data.

Types

type ExtractOptions

type ExtractOptions struct {
	OnEntry TarObserver
}

type TarEntry

type TarEntry struct {
	Name     string
	Size     int64
	Mode     fs.FileMode
	Type     byte
	Linkname string
	ModTime  time.Time
}

type TarObserver

type TarObserver func(entry TarEntry)

Jump to

Keyboard shortcuts

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