Documentation
¶
Index ¶
Constants ¶
const (
MaxPathLen = 4096
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DirectoryPath ¶
type DirectoryPath struct { Name string Depth int Parent *DirectoryPath }
DirectoryPath represents a linked-list of path parts, which the next element being the parent directory.
func (*DirectoryPath) AppendTo ¶
func (d *DirectoryPath) AppendTo(p []byte) []byte
AppendTo will append the full path to the given byte slice, returning the slice.
func (*DirectoryPath) Less ¶
func (d *DirectoryPath) Less(e *DirectoryPath) bool
Less implements the sort.Interface interface.
type FileInfo ¶
type FileInfo struct { Path *DirectoryPath Name []byte Size int64 ApparentSize int64 UID uint32 GID uint32 MTime int64 ATime int64 CTime int64 Inode int64 EntryType byte }
FileInfo represents the parsed information about a file or directory.
type GroupUserID ¶
type GroupUserID uint64
GroupUserID is a combined GID and UID.
func NewGroupUserID ¶
func NewGroupUserID(gid, uid uint32) GroupUserID
NewGroupUserID create a new GroupUserID.
type Operation ¶
type Operation interface { // Add is called once for the containing directory and for each of its // descendents during a Summariser.Summarise() call. Add(info *FileInfo) error // Output is called when we return to the parent directory during a // Summariser.Summarise() call, having processed all descendent entries. // // For an Operation working on a directory, this method must also do any // necessary reset of the instance of the type before returning. Output() error }
Operation is a type that receives file information either for a directory, and it's descendants, or for an entire tree.
type OperationGenerator ¶
type OperationGenerator func() Operation
OperationGenerator is used to generate an Operation for a Summariser.Summarise() run.
Will be called a single time as a Global Operator and multiple times as a Directory Operator.
type Summariser ¶
type Summariser struct {
// contains filtered or unexported fields
}
Summariser provides methods to register Operators that act on FileInfo entries in a tree.
func NewSummariser ¶
func NewSummariser(p *stats.StatsParser) *Summariser
NewSummariser returns a new Summariser that will read from the given stats.StatsParser.
func (*Summariser) AddDirectoryOperation ¶
func (s *Summariser) AddDirectoryOperation(op OperationGenerator)
AddDirectoryOperation will add an operation that will be created for each directory, receiving information for all of its descendants.
func (*Summariser) AddGlobalOperation ¶
func (s *Summariser) AddGlobalOperation(op OperationGenerator)
AddGlobalOperation will add an operation that will be passed information for every file parsed.
func (*Summariser) Summarise ¶
func (s *Summariser) Summarise() error
Summarise will read from the stats.StatsParser and pass that information to the Operations it has been given.
type Summary ¶
Summary holds count and size and lets you accumulate count and size as you add more things with a size.
type SummaryWithTimes ¶
type SummaryWithTimes struct { Summary Atime int64 // seconds since Unix epoch Mtime int64 // seconds since Unix epoch }
SummaryWithTimes is like summary, but also holds the reference time, oldest atime, newest mtime add()ed.
func (*SummaryWithTimes) Add ¶
func (s *SummaryWithTimes) Add(size int64, atime int64, mtime int64)
Add will increment our count and add the given size to our size. It also stores the given atime if it is older than our current one, and the given mtime if it is newer than our current one.
func (*SummaryWithTimes) AddSummary ¶
func (s *SummaryWithTimes) AddSummary(t *SummaryWithTimes)
AddSummary add the data in the passed SummaryWithTimes to the existing SummaryWithTimes.