Documentation ¶
Overview ¶
Package archive defines a set of functions for reading and writing directories and files in a number of tar formats.
Index ¶
- Variables
- func CreateSingleFileTar(tarFile, path, txt string) error
- func CreateSingleFileTarReader(path, txt string) io.ReadCloser
- func GenerateTar(genFn func(TarWriter) error) io.ReadCloser
- func GenerateTarWithWriter(genFn func(TarWriter) error, twf TarWriterFactory) io.ReadCloser
- func IsEntryNotExist(err error) bool
- func IsZip(file io.Reader) (bool, error)
- func NormalizeHeader(header *tar.Header, normalizeModTime bool)
- func ReadDirAsTar(srcDir, basePath string, uid, gid int, mode int64, normalizeModTime bool, ...) io.ReadCloser
- func ReadTarEntry(rc io.Reader, entryPath string) (*tar.Header, []byte, error)
- func ReadZipAsTar(srcPath, basePath string, uid, gid int, mode int64, normalizeModTime bool, ...) io.ReadCloser
- func WriteDirToTar(tw TarWriter, srcDir, basePath string, uid, gid int, mode int64, ...) error
- func WriteZipToTar(tw TarWriter, srcZip, basePath string, uid, gid int, mode int64, ...) error
- type TarBuilder
- func (t *TarBuilder) AddDir(path string, mode int64, modTime time.Time)
- func (t *TarBuilder) AddFile(path string, mode int64, modTime time.Time, contents []byte)
- func (t *TarBuilder) Reader(twf TarWriterFactory) io.ReadCloser
- func (t *TarBuilder) WriteTo(w io.Writer, twf TarWriterFactory) (int64, error)
- func (t *TarBuilder) WriteToPath(path string, twf TarWriterFactory) error
- type TarWriter
- type TarWriterFactory
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEntryNotExist = errors.New("not exist")
ErrEntryNotExist is an error returned if an entry path doesn't exist
View Source
var NormalizedDateTime time.Time
Functions ¶
func CreateSingleFileTar ¶
func CreateSingleFileTarReader ¶
func CreateSingleFileTarReader(path, txt string) io.ReadCloser
func GenerateTar ¶
func GenerateTar(genFn func(TarWriter) error) io.ReadCloser
func GenerateTarWithWriter ¶
func GenerateTarWithWriter(genFn func(TarWriter) error, twf TarWriterFactory) io.ReadCloser
GenerateTarWithTar returns a reader to a tar from a generator function using a writer from the provided factory. Note that the generator will not fully execute until the reader is fully read from. Any errors returned by the generator will be returned when reading the reader.
func IsEntryNotExist ¶
IsEntryNotExist detects whether a given error is of type ErrEntryNotExist
func NormalizeHeader ¶
NormalizeHeader normalizes a tar.Header
Normalizes the following:
- ModTime
- GID
- UID
- User Name
- Group Name
func ReadDirAsTar ¶
func ReadTarEntry ¶
ReadTarEntry reads and returns a tar file
func ReadZipAsTar ¶
Types ¶
type TarBuilder ¶
type TarBuilder struct {
// contains filtered or unexported fields
}
func (*TarBuilder) Reader ¶
func (t *TarBuilder) Reader(twf TarWriterFactory) io.ReadCloser
func (*TarBuilder) WriteTo ¶
func (t *TarBuilder) WriteTo(w io.Writer, twf TarWriterFactory) (int64, error)
func (*TarBuilder) WriteToPath ¶
func (t *TarBuilder) WriteToPath(path string, twf TarWriterFactory) error
type TarWriterFactory ¶
func DefaultTarWriterFactory ¶
func DefaultTarWriterFactory() TarWriterFactory
Click to show internal directories.
Click to hide internal directories.