stuffbin: github.com/knadh/stuffbin Index | Files | Directories

package stuffbin

import "github.com/knadh/stuffbin"

Index

Package Files

fs.go stuff.go unstuff.go

Variables

var ErrNoID = errors.New("no ID found in the file")

ErrNoID is used to indicate if an ID was found in a file or not.

var ErrNotSupported = errors.New("this method is not supported")

ErrNotSupported indicates interface methods that are implemented but not supported.

func GetStuff Uses

func GetStuff(in string) ([]byte, error)

GetStuff takes the path to a stuffed binary and extracts the packed data.

func MergeFS Uses

func MergeFS(dest FileSystem, src FileSystem) error

MergeFS merges FileSystem b into a, overwriting conflicting paths.

func ParseTemplates Uses

func ParseTemplates(f template.FuncMap, fs FileSystem, path ...string) (*template.Template, error)

ParseTemplates takes a file system, a list of file paths, and parses them into a template.Template.

func ParseTemplatesGlob Uses

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.

func Stuff Uses

func Stuff(in, out, rootPath string, files ...string) (int64, int64, error)

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 Uses

type File struct {
    // contains filtered or unexported fields
}

File represents an abstraction over http.File.

func NewFile Uses

func NewFile(path string, info os.FileInfo, b []byte) *File

NewFile creates and returns a new instance of File.

func (*File) Close Uses

func (f *File) Close() error

Close emulates http.File's Close but internally, it simply seeks the File's reader to 0.

func (*File) Path Uses

func (f *File) Path() string

Path returns the path of the file.

func (*File) Read Uses

func (f *File) Read(b []byte) (int, error)

Read reads the file contents.

func (*File) ReadBytes Uses

func (f *File) ReadBytes() []byte

ReadBytes returns the bytes of the given file.

func (*File) Readdir Uses

func (f *File) Readdir(count int) ([]os.FileInfo, error)

Readdir is a dud.

func (*File) Seek Uses

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek seeks the given offset in the file.

func (*File) Stat Uses

func (f *File) Stat() (os.FileInfo, error)

Stat returns the file's os.FileInfo.

type FileSystem Uses

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 Uses

func NewFS() (FileSystem, error)

NewFS returns a new instance of FileSystem.

func NewLocalFS Uses

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 Uses

func UnStuff(path string) (FileSystem, error)

UnStuff takes the path to a stuffed binary, unstuffs it, and returns a FileSystem.

func UnZip Uses

func UnZip(b []byte) (FileSystem, error)

UnZip unzips zipped bytes and returns a FileSystem with the files mapped to it.

type ID Uses

type ID struct {
    Name    [8]byte
    BinSize uint64
    ZipSize uint64
}

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.

func GetFileID Uses

func GetFileID(fName string) (ID, error)

GetFileID attempts to get the stuffbin identifier from the end of the file and returns the identifier name and file sizes.

type WalkFunc Uses

type WalkFunc func(srcPath, targetPath string, fInfo os.FileInfo) error

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.

Directories

PathSynopsis
mock
stuffbin

Package stuffbin imports 11 packages (graph) and is imported by 7 packages. Updated 2020-09-22. Refresh now. Tools for package owners.