Documentation ¶
Overview ¶
Package filestat defines and implements basic file statistics interface
Package fh implements basic hashing functionality
Index ¶
Constants ¶
const ( Idle = "" MD5 = "md5" SHA1 = "sha1" SHA256 = "sha256" SHA512 = "sha512" )
const EMPTY_CHECKSUM = "-"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSizeLesserFunc ¶
func NewFileSizeLesserFunc ¶
func NewFileSizeLesserFunc(maxSize int64, inBlocks bool) FileSizeLesserFunc
type FileStat ¶
type FileStat interface { // Path - full path (abs cleaned resolved) Path() string // BaseName - file name wo dirs BaseName() string // Inode - Unix inode (or analogue) used here to resolve multiple links to the same file content Inode() Inode // IsRegular - checks whether file is regular (FileMode & ModeType == 0) IsRegular() bool // Size - content size Size() int64 // Blksize - block size of file (file system specific) Blksize() int64 // Blocks - number of blocks occupied by file (here it's calculated as Blocks = Ceil (Size / Blksize) ) Blocks() int64 // ModTime - modification time ModTime() time.Time // Perm - Unix permission bits (or analogue) Perm() fs.FileMode // User - user owner of file User() *user.User // Group - group owner of file Group() *user.Group // Symlink - initial (from search matching) link to this file Symlink() FileStat // MetaKey - custom key based on file metadata (such as name, size, uid:gid, perm, ...) // Note: content itself is ignored - see FileStatMetaKeyFunc for details MetaKey() string // String - pretty string for view (like ls -i) String() string // Prior() string // SortingKey - sorting key for output SortingKey() string }
FileStat describes a file (use GetFileStat)
func GetFileStat ¶
func GetFileStat(path string, metaKeyFunc MetaKeyFunc, priorFunc PriorFunc, SymLinkEnabled bool) (FileStat, error)
GetFileStat - FileStat builder function (uses os specific func newFileStat)
type FileStatValidatorFunc ¶
func NewRegularSizeStatValidator ¶
func NewRegularSizeStatValidator(minSize, maxSize int64) FileStatValidatorFunc
todo: make validators stack
type HashFileFunc ¶
HashFileFunc - type specifies signature of function that calculates hash / checksum for file path initial settings (algo, size, etc.) are taken from closure - see GetHashFileFunc
func GetHashFileFunc ¶
func GetHashFileFunc(algo string, ndMaxSize int64, inBlocks bool) (HashFileFunc, error)
GetHashFileFunc customizes hasher func
type MetaKeyFunc ¶
FileStatMetaKeyFunc - func type for meta key builder (used in FileStat.MetaKey()) see NewMetaKeyFunc
func NewMetaKeyFunc ¶
func NewMetaKeyFunc(bSize bool, bName bool, bPerm bool, bUID bool, bGID bool, bModTime bool) MetaKeyFunc
NewMetaKeyFunc customizes meta key builder function (enclosure for FileStatMetaKeyFunc) todo: make keys set order to be also customizable - thus, it will be possible to set sorting order by meta key.