import "github.com/knadh/stuffbin"
ErrNoID is used to indicate if an ID was found in a file or not.
ErrNotSupported indicates interface methods that are implemented but not supported.
GetStuff takes the path to a stuffed binary and extracts the packed data.
func MergeFS(dest FileSystem, src FileSystem) error
MergeFS merges FileSystem b into a, overwriting conflicting paths.
ParseTemplates takes a file system, a list of file paths, and parses them into a template.Template.
func ParseTemplatesGlob(f template.FuncMap, fs FileSystem, pattern string) (*template.Template, error)
ParseTemplatesGlob takes a file system, a file path pattern, and parses matching files into a template.Template with an optional template.FuncMap that will be applied to the compiled templates.
Stuff takes the path to a binary, a list of file paths to stuff, and compresses the files and appends them to the end of the binary's body and writes everything to a new binary.
type File struct {
// contains filtered or unexported fields
}
File represents an abstraction over http.File.
NewFile creates and returns a new instance of File.
Close emulates http.File's Close but internally, it simply seeks the File's reader to 0.
Path returns the path of the file.
Read reads the file contents.
ReadBytes returns the bytes of the given file.
Readdir is a dud.
Seek seeks the given offset in the file.
Stat returns the file's os.FileInfo.
type FileSystem interface { Add(f *File) error List() []string Len() int Size() int64 Get(path string) (*File, error) Glob(pattern string) ([]string, error) Read(path string) ([]byte, error) Open(path string) (http.File, error) Delete(path string) error Merge(f FileSystem) error FileServer() http.Handler }
FileSystem represents a simple filesystem abstraction that implements the http.fileSystem interface.
func NewFS() (FileSystem, error)
NewFS returns a new instance of FileSystem.
func NewLocalFS(rootPath string, paths ...string) (FileSystem, error)
NewLocalFS returns a new instance of FileSystem with the given list of local files and directories mapped to it.
func UnStuff(path string) (FileSystem, error)
UnStuff takes the path to a stuffed binary, unstuffs it, and returns a FileSystem.
func UnZip(b []byte) (FileSystem, error)
UnZip unzips zipped bytes and returns a FileSystem with the files mapped to it.
ID represents an identifier that is appended to binaries for identifying stuffbin binaries. The fields are appended as bytes totalling 8 + 12 + 8 + 8 = 36 bytes in the order Name BinSize ZipSize.
GetFileID attempts to get the stuffbin identifier from the end of the file and returns the identifier name and file sizes.
WalkFunc is an abstraction over filepath.WalkFunc that's used as a callback to receive the real file path and their corresponding target (alias) paths from a real filepath.Walk() traversal of a list of file and directory paths.
Path | Synopsis |
---|---|
mock | |
stuffbin |
Package stuffbin imports 11 packages (graph) and is imported by 7 packages. Updated 2020-09-22. Refresh now. Tools for package owners.