Documentation ¶
Overview ¶
Package util contains various utility functions used by other packages
Index ¶
- func AsciizToString(data []byte) string
- func BufreaderAt(r io.ReadSeeker, offset int64) (*bufio.Reader, error)
- func CreateFile(filename string) (*os.File, error)
- func DecodeString(bs []byte) ([]byte, error)
- func Extensions(filename string) []string
- func HashFile(filename string) ([]byte, error)
- func HashStream(r io.Reader) ([]byte, error)
- func Mkdir(path string) error
- func NewEmptyDir(dirname string) error
- func NewReaderAt(r io.ReadSeeker) io.ReaderAt
- func ParseNumber(str string, bits int) (uint64, error)
- func Process(r io.ByteReader, p func(b uint8, n int) bool) (int, error)
- func ReadUntil(r io.Reader, until byte, maxsize int) ([]byte, bool, error)
- func RegisterFatal(v interface{})
- func RegisterFatalf(format string, v ...interface{})
- func RegisterWarningf(format string, v ...interface{})
- func SanitizeFilename(filename string) string
- func Warnings() []string
- type FileList
- type Function
- type FunctionDatabase
- type PathType
- type Register
- func (r Register) Get(name string, def interface{}) (interface{}, bool)
- func (r Register) GetBoolean(name string, def bool) (bool, bool)
- func (r Register) GetString(name string, def string) (string, bool)
- func (r *Register) Set(name string, val interface{})
- func (r Register) SetBoolean(name string, val bool)
- func (r Register) SetNumber(name string, val uint64)
- func (r *Register) SetParent(parent *Register)
- func (r Register) SetString(name string, val string)
- func (r Register) Walk(visitor func(key string, val interface{}) bool)
- type Structured
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsciizToString ¶
AsciizToString converts a null terminated byte array to a string
func BufreaderAt ¶
BufreaderAt is a helper for creating a buffered reader at a position
func CreateFile ¶
CreateFile creates a file, adds missing directories
func DecodeString ¶
func Extensions ¶
Extensions returns all extensions of a file, e.g. a.tar.gz -> ["gz","tar"]
func HashStream ¶
HashStream is similar to HashFile but operates on streams
func NewEmptyDir ¶
NewEmptyDir accepts a new or empty dir and if new creates it
func NewReaderAt ¶
func NewReaderAt(r io.ReadSeeker) io.ReaderAt
NewReaderAt turns a ReadSeeker into a ReaderAt for the rare cases its needed
func ParseNumber ¶
ParseNumber parses number from string, handles 0x, 0o and 0b prefixes
func ReadUntil ¶
ReadUntil reads from stream until it sees byte "until" or gathers "maxsize" bytes (ignored if zero or less)
func RegisterFatalf ¶
func RegisterFatalf(format string, v ...interface{})
RegisterFatalf regiters a fatal error
func RegisterWarningf ¶
func RegisterWarningf(format string, v ...interface{})
RegisterWarningf regiters a warning that will be printed and recorded
func SanitizeFilename ¶
SanitizeFilename performs file name sanitization
Types ¶
type FileList ¶
FileList is a list of files, including files in folders
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function represents a call to a golang function with the following format
func(param1, param2, ...) (ret1, ...)
func NewFunction ¶
type FunctionDatabase ¶
type FunctionDatabase struct { Functions map[string]*Function // contains filtered or unexported fields }
FunctionDatabase is a database of cuntion with a given prototype
func NewFunctionDatabase ¶
func NewFunctionDatabase(prototype interface{}) (*FunctionDatabase, error)
func (FunctionDatabase) Find ¶
func (db FunctionDatabase) Find(name string) (*Function, bool)
Find finds among registered functions
func (FunctionDatabase) Register ¶
func (db FunctionDatabase) Register(name string, fun interface{}) error
Register registers a user function
type PathType ¶
type PathType int
PathType is type of a path such as /tmp, i.e. wether its a file or a dir etc
type Register ¶
type Register struct {
// contains filtered or unexported fields
}
func NewRegister ¶
func NewRegister() *Register
func (Register) SetBoolean ¶
type Structured ¶
type Structured struct { Reader io.ReadSeeker Order binary.ByteOrder }
Structured define a file that has a stream and a byteorder
func (Structured) Read ¶
func (bf Structured) Read(data interface{}) error
Read reads structred data from the stream
func (Structured) ReadAt ¶
func (bf Structured) ReadAt(offset int64, data interface{}) error
ReadAt reads structred data from a given offset