Documentation ¶
Index ¶
- func TarGzipReader(r io.Reader) (*tar.Reader, func() error, error)
- func Walkers(convertReader buffer.ReaderReaderAtConverter, fileOpenMode FileOpenMode) func(path string) (WalkerProvider, bool)
- type FileOpenMode
- type FileWalkFn
- type FileWalkerProviderFunc
- type ReaderWalkerProviderFunc
- type WalkCloser
- type WalkerProvider
- func TarArchiveWalkers(mode FileOpenMode) WalkerProvider
- func TarBz2Walkers(mode FileOpenMode) WalkerProvider
- func TarGzWalkers(mode FileOpenMode) WalkerProvider
- func WalkerFromReaderWalkerProvider(mode FileOpenMode, getReaderWalker ReaderWalkerProviderFunc) WalkerProvider
- func WalkerProviderFromFuncs(file FileWalkerProviderFunc, reader ReaderWalkerProviderFunc) WalkerProvider
- func ZipArchiveWalkers(converter buffer.ReaderReaderAtConverter) WalkerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TarGzipReader ¶ added in v1.0.0
TarGzipReader creates a reader for gzipped tar content. The returned function should be called to release all underlying resources.
func Walkers ¶ added in v1.4.0
func Walkers(convertReader buffer.ReaderReaderAtConverter, fileOpenMode FileOpenMode) func(path string) (WalkerProvider, bool)
Walkers creates a function that will return a WalkerProvider for a file path if there is one supported. The bool returned will be true if the path is supported, false otherwise.
When creating a walker from a reader, if the type of archive requires that the content must be available as a ReaderAt, then the buffer.ReaderReaderAtConverter will be used to convert the Reader to a ReaderAt.
The given FileOpenMode will determine whether a file used standard file opening or direct I/O. Standard file opening may put pressure on the filesystem cache under certain circumstances, resulting in extra work for the filesystem due to cache eviction. Direct I/O may be enabled which will skip the filesystem cache for operating systems that support it. With Direct I/O enabled, it will only be used for archives where reading through the stream is required to find file headers rather than for archives where a file table can be located and skipped to at a known place. e.g. Direct I/O may be used for tar-based archives, but will not be used for zip-based archives.
Types ¶
type FileOpenMode ¶ added in v1.4.0
type FileOpenMode bool
FileOpenMode is the behaviour used when opening a file on disk.
const ( // StandardOpen opens files using read only flags. StandardOpen FileOpenMode = false // DirectIOOpen opens files using flags that allow for direct i/o, skipping filesystem cache. DirectIOOpen FileOpenMode = true )
type FileWalkFn ¶ added in v0.5.0
type FileWalkFn func(ctx context.Context, path string, size int64, contents io.Reader) (proceed bool, err error)
FileWalkFn is called by a WalkFn on each file contained in an archive.
type FileWalkerProviderFunc ¶ added in v1.0.0
type FileWalkerProviderFunc func(path string) (WalkCloser, error)
FileWalkerProviderFunc creates a WalkFn and closing function from a file.
type ReaderWalkerProviderFunc ¶ added in v1.0.0
type ReaderWalkerProviderFunc func(r io.Reader, size int64) (WalkCloser, error)
ReaderWalkerProviderFunc creates a WalkFn and closing function from a reader.
type WalkCloser ¶ added in v1.9.0
WalkCloser iterates through an archive when Walk is called, calling FileWalkFn on each member file.
type WalkerProvider ¶ added in v1.0.0
type WalkerProvider interface { FromFile(string) (WalkCloser, error) FromReader(io.Reader, int64) (WalkCloser, error) }
WalkerProvider creates WalkFn and closing function from certain resources.
func TarArchiveWalkers ¶ added in v1.0.0
func TarArchiveWalkers(mode FileOpenMode) WalkerProvider
TarArchiveWalkers creates a WalkerProvider for tar content.
func TarBz2Walkers ¶ added in v1.0.0
func TarBz2Walkers(mode FileOpenMode) WalkerProvider
TarBz2Walkers creates a WalkerProvider for bz2 zipped tar content.
func TarGzWalkers ¶ added in v1.0.0
func TarGzWalkers(mode FileOpenMode) WalkerProvider
TarGzWalkers creates a WalkerProvider for gzipped tar content.
func WalkerFromReaderWalkerProvider ¶ added in v1.0.0
func WalkerFromReaderWalkerProvider(mode FileOpenMode, getReaderWalker ReaderWalkerProviderFunc) WalkerProvider
WalkerFromReaderWalkerProvider creates IntermediateBufferReader WalkerProvider where the same function is used for both the FromFile and FromReader methods. For the FromFile, the file pointer is passed directly to reader.
func WalkerProviderFromFuncs ¶ added in v1.0.0
func WalkerProviderFromFuncs(file FileWalkerProviderFunc, reader ReaderWalkerProviderFunc) WalkerProvider
WalkerProviderFromFuncs creates a WalkerProvider from the given file and reader functions.
func ZipArchiveWalkers ¶ added in v1.0.0
func ZipArchiveWalkers(converter buffer.ReaderReaderAtConverter) WalkerProvider
ZipArchiveWalkers creates a WalkerProvider for zipped file content. convertReader is used to convert a Reader to a ReaderAt.