types

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncExtract

type FuncExtract func(fs.FileInfo, io.ReadCloser, string, string) bool

type Reader

type Reader interface {
	io.Closer

	// List try to return a slice of all path into the archive or an error.
	List() ([]string, error)
	// Info returns the file information as fs.FileInfo for the given path or an error.
	//
	// Parameters:
	// - string: the path of the embedded file into the archive to get information for.
	//
	// Returns:
	// - fs.FileInfo: the file information for the given path.
	// - error: an error if the file information could not be retrieved.
	Info(string) (fs.FileInfo, error)
	// Get retrieves an io.ReadCloser or an error based on the provided file path.
	//
	// Parameters:
	// - string: the path of the embedded file into the archive to get information for.
	//
	// Returns:
	// - io.ReadCloser: the read/close stream for the given path.
	// - error: an error if the file information could not be retrieved.
	Get(string) (io.ReadCloser, error)
	// Has will check if the archive contains the given path.
	//
	// Parameters:
	// - string: the path of the embedded file into the archive to get information for.
	//
	// Returns:
	// - bool: true if the archive contains the given path.
	Has(string) bool
	// Walk applies the given function to each element in the archive.
	//
	// Parameters:
	// - FuncExtract: the function will be call on each item in the archive.
	// The function can return false to stop or true to continue the walk.
	// The function will accept the following parameters:
	// - fs.FileInfo: the file information for the given path.
	// - io.ReadCloser: the read/close stream for the given path.
	// - string: the path of the embedded file into the archive.
	// - string: the link target of the embedded file if it is a link or a symlink.
	Walk(FuncExtract)
}

type ReplaceName

type ReplaceName func(string) string

type Writer

type Writer interface {
	io.Closer

	// Add will add the given file into the archive.
	//
	// Parameter(s):
	//   - fs.FileInfo: the file information for the given path (permission, size, etc...).
	//   - io.ReadCloser: the read/close stream to read the data and store it into the archive.
	//   - string: use to force a different pathname for the embedded file into the archive.
	//   - string: use to specify the target if the embedded file is a link.
	// Return type: error
	Add(fs.FileInfo, io.ReadCloser, string, string) error

	// FromPath will parse recursively the given path and add it into the archive
	//
	// Parameter(s):
	//   - string: the source path to parse recursively and add into the archive.
	//   - string: a filtering string to accept only certain files (empty do disable filtering).
	//   - ReplaceName: a function to replace the name of the embedded file, if needed.
	// Returns error if triggered
	FromPath(string, string, ReplaceName) error
}

Jump to

Keyboard shortcuts

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