assist

package
v0.0.0-...-3388463 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTarFile

func ExtractTarFile(dst string, tarFile string, adjustLink bool, skipUnNormalFile bool) error

ExtractTarFile untars a single file from a given src to a destination

adjustLink: Whether to automatically correct the symbolic link, only the absolute path is affected, and the symbolic link based on relative path is not affected

For example, suppose we have a tar file:

tar
├── file_1
└── file_2 -> /file_1

and want to extract to dir '/target',

If adjustLink set to false, then the target dir looks like:

target
├── file_1
└── file_2 -> /file_1   # symlink broken, it not really point to file_1, since it's an abs path

yes, it is same with files in tarball

And if adjustLink set to true, the target dir will become:

target
├── file_1
└── file_2 -> /target/file_1

as you can see, file_2's symlink was auto adjusted to /target/file_1

func Tar

func Tar(src string, isGzip bool, writers ...io.Writer) error

Tar takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func Untar

func Untar(dst string, isGzip bool, adjustLink bool, r io.Reader, skipUnNormalFile bool) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

Types

This section is empty.

Jump to

Keyboard shortcuts

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