Documentation ¶
Index ¶
- func GetTarSize(dat []byte) (int, error)
- func GetTargetFileNames(dst string, archive io.Reader) ([]string, error)
- func GetTargetFolderNames(dst string, archive io.Reader) ([]string, error)
- func IsSingleFileArchive(archive []byte) bool
- func PackFolder(src string, buf io.Writer) error
- func UnpackFile(dst, fname string, archive io.Reader, dest io.Writer) error
- type ConcatReader
- type Reader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTarSize ¶
GetTarSize will return the actual size of the tar file for a byte array containing padded tar data.
func GetTargetFileNames ¶
GetTargetFileNames will return all file names in the archive provided.
func GetTargetFolderNames ¶
GetTargetFolderNames will return all affected folders in the archive provided.
func IsSingleFileArchive ¶
IsSingleFileArchive will return true if there is only 1 file stored in the given archive.
func PackFolder ¶
PackFolder will write the given folder as a tar to the given Writer.
Types ¶
type ConcatReader ¶
type ConcatReader struct {
// contains filtered or unexported fields
}
ConcatReader is an io.Reader that first returns data from a wrapped bytes slice and then continues to return data from a wrapped io.Reader
func NewConcatReader ¶
func NewConcatReader(data []byte, reader io.Reader) *ConcatReader
func (*ConcatReader) ReadBytes ¶
func (r *ConcatReader) ReadBytes() int
ReadBytes returns the number of read bytes
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is able to read tar archive uncompressed, compressed with gzip, xz, or bzip2
func (*Reader) Next ¶
Next advances to the next entry in the tar archive. The Header.Size determines how many bytes can be read for the next file. Any remaining data in the current file is automatically discarded. At the end of the archive, Next returns the error io.EOF.
If Next encounters a non-local name (as defined by filepath.IsLocal) and the GODEBUG environment variable contains `tarinsecurepath=0`, Next returns the header with an [ErrInsecurePath] error. A future version of Go may introduce this behavior by default. Programs that want to accept non-local names can ignore the [ErrInsecurePath] error and use the returned header.
func (*Reader) Read ¶
Read reads from the current file in the tar archive. It returns (0, io.EOF) when it reaches the end of that file, until [Next] is called to advance to the next file.
If the current file is sparse, then the regions marked as a hole are read back as NUL-bytes.
Calling Read on special types like [TypeLink], [TypeSymlink], [TypeChar], [TypeBlock], [TypeDir], and [TypeFifo] returns (0, io.EOF) regardless of what the [Header.Size] claims.