Documentation ¶
Index ¶
- Constants
- func Copy(src, dst string) error
- func CreateDateFuncs() template.FuncMap
- func FileMD5(path string) (hash string, err error)
- func FindLine(path string, b []byte) string
- func GuessCompressed(path string) bool
- func HashHex(h hash.Hash) string
- func InitPath(root string, path string, isdir bool) (string, error)
- func LoadJSON(path string, data interface{}) error
- func Move(src, dst string) error
- func PartialMD5(path string, start int64, end int64) (hash string, err error)
- func ReadableMD5(handle sts.Readable) (hash string, err error)
- func Readdir(dirname string) ([]os.FileInfo, error)
- func StringMD5(data string) string
- func Walk(root string, walkFn filepath.WalkFunc, followSymLinks bool) (err error)
- func WriteHumanJSON(path string, data interface{}) (err error)
- func WriteJSON(path string, data interface{}) (err error)
- type PathMap
- type PathMapper
Constants ¶
const BlockSize = 8192
BlockSize is the number of bytes read into memory.
const LockExt = ".lck"
LockExt is the file extension added to file names as contents are written.
Variables ¶
This section is empty.
Functions ¶
func CreateDateFuncs ¶
func FindLine ¶
FindLine searches the given file for the provided byte array and returns that line if found.
func GuessCompressed ¶
GuessCompressed attempts to determine if a file is compressed.
func InitPath ¶
InitPath will turn a relative path into absolute (based on root) and make sure it exists.
func LoadJSON ¶
LoadJSON reads the file at specified path and decodes the JSON into the specified struct. The input data struct should be a pointer.
func Move ¶
Move moves a file from one path to another. It attempts to do a rename and, if that fails, will instead do a copy followed by a deletion of the original. If the destination file already exists it will be overwritten.
func PartialMD5 ¶
PartialMD5 computes the MD5 of part of a file, specified from start byte to end byte.
func ReadableMD5 ¶
ReadableMD5 computes the MD5 on a sts.Readable instance
func Readdir ¶
Readdir is a simple wrapper around File.Readdir that accepts a path argument as opposed to a file pointer.
func Walk ¶
Walk mimics https://golang.org/pkg/path/filepath/#Walk wih the exceptions that 1) it allows for the option to follow symbolic links, and 2) the order of the calls to walkFn are NOT deterministic (i.e. no lexical ordering).
func WriteHumanJSON ¶
WriteHumanJSON writes the input data in a human-readable JSON format to the specified path.
Types ¶
type PathMap ¶
type PathMap struct { Pattern *regexp.Regexp Template string Funcs template.FuncMap ExtraVars map[string]string Stat func(string) time.Time }
PathMap houses a single translation from a pattern to a string template used to generate the mapping from an input path to an output name
type PathMapper ¶
PathMapper houses an ordered list of translations for one path to another
func (*PathMapper) Translate ¶
func (pm *PathMapper) Translate(inputPath string) string
Translate takes an input path and returns the first valid output name generated by one of the configured mappings