Documentation ¶
Index ¶
- func CmdStream(cmd *exec.Cmd) (io.Reader, error)
- func CopyFileWithTar(src, dst string) error
- func CopyWithTar(src, dst string) error
- func Tar(path string, compression Compression) (io.Reader, error)
- func TarFilter(path string, compression Compression, filter []string) (io.Reader, error)
- func TarUntar(src string, filter []string, dst string) error
- func Untar(archive io.Reader, path string) error
- func UntarPath(src, dst string) error
- type Archive
- type Compression
- type TempArchive
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CmdStream ¶
CmdStream executes a command, and returns its stdout as a stream. If the command fails to run or doesn't complete successfully, an error will be returned, including anything written on stderr.
func CopyFileWithTar ¶
CopyFileWithTar emulates the behavior of the 'cp' command-line for a single file. It copies a regular file from path `src` to path `dst`, and preserves all its metadata.
If `dst` ends with a trailing slash '/', the final destination path will be `dst/base(src)`.
func CopyWithTar ¶
CopyWithTar creates a tar archive of filesystem path `src`, and unpacks it at filesystem path `dst`. The archive is streamed directly with fixed buffering and no intermediary disk IO.
func Tar ¶
func Tar(path string, compression Compression) (io.Reader, error)
Tar creates an archive from the directory at `path`, and returns it as a stream of bytes.
func TarFilter ¶
Tar creates an archive from the directory at `path`, only including files whose relative paths are included in `filter`. If `filter` is nil, then all files are included.
func TarUntar ¶
TarUntar is a convenience function which calls Tar and Untar, with the output of one piped into the other. If either Tar or Untar fails, TarUntar aborts and returns the error.
func Untar ¶
Untar reads a stream of bytes from `archive`, parses it as a tar archive, and unpacks it into the directory at `path`. The archive may be compressed with one of the following algorithms:
identity (uncompressed), gzip, bzip2, xz.
FIXME: specify behavior when target path exists vs. doesn't exist.
Types ¶
type Compression ¶
type Compression uint32
const ( Uncompressed Compression = iota Bzip2 Gzip Xz )
func DetectCompression ¶
func DetectCompression(source []byte) Compression
func (*Compression) Extension ¶
func (compression *Compression) Extension() string
func (*Compression) Flag ¶
func (compression *Compression) Flag() string
type TempArchive ¶
func NewTempArchive ¶
func NewTempArchive(src Archive, dir string) (*TempArchive, error)
NewTempArchive reads the content of src into a temporary file, and returns the contents of that file as an archive. The archive can only be read once - as soon as reading completes, the file will be deleted.