summary

package
v5.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ErrInvalidType = Error("not a valid file type")
	ErrInvalidAge  = Error("not a valid age")
)
View Source
const (
	SecondsInAMonth = 2628000
	SecondsInAYear  = SecondsInAMonth * 12
)

Variables

Functions

func FitsAgeInterval added in v5.1.0

func FitsAgeInterval(dguta GUTAKey, atime, mtime, refTime int64) bool

FitsAgeInterval takes a dguta and the mtime and atime and reference time. It checks the value of age inside the dguta, and then returns true if the mtime or atime respectively fits inside the age interval. E.g. if age = 3, this corresponds to DGUTAgeA6M, so atime is checked to see if it is older than 6 months.

Types

type DirGUTAFileType added in v5.1.0

type DirGUTAFileType uint8

DirGUTAFileType is one of the special file types that the directory,group,user,filetype,age summaries group on.

const (
	DGUTAFileTypeOther      DirGUTAFileType = 0
	DGUTAFileTypeTemp       DirGUTAFileType = 1
	DGUTAFileTypeVCF        DirGUTAFileType = 2
	DGUTAFileTypeVCFGz      DirGUTAFileType = 3
	DGUTAFileTypeBCF        DirGUTAFileType = 4
	DGUTAFileTypeSam        DirGUTAFileType = 5
	DGUTAFileTypeBam        DirGUTAFileType = 6
	DGUTAFileTypeCram       DirGUTAFileType = 7
	DGUTAFileTypeFasta      DirGUTAFileType = 8
	DGUTAFileTypeFastq      DirGUTAFileType = 9
	DGUTAFileTypeFastqGz    DirGUTAFileType = 10
	DGUTAFileTypePedBed     DirGUTAFileType = 11
	DGUTAFileTypeCompressed DirGUTAFileType = 12
	DGUTAFileTypeText       DirGUTAFileType = 13
	DGUTAFileTypeLog        DirGUTAFileType = 14
	DGUTAFileTypeDir        DirGUTAFileType = 15
)

func FileTypeStringToDirGUTAFileType added in v5.1.0

func FileTypeStringToDirGUTAFileType(ft string) (DirGUTAFileType, error)

FileTypeStringToDirGUTAFileType converts the String() representation of a DirGUTAFileType back in to a DirGUTAFileType. Errors if an invalid string supplied.

func (DirGUTAFileType) String added in v5.1.0

func (d DirGUTAFileType) String() string

String lets you convert a DirGUTAFileType to a meaningful string.

type DirGUTAge added in v5.1.0

type DirGUTAge uint8

DirGUTAge is one of the age types that the directory,group,user,filetype,age summaries group on. All is for files of all ages. The AgeA* consider age according to access time. The AgeM* consider age according to modify time. The *\dM ones are age in the number of months, and the *\dY ones are in number of years.

const (
	DGUTAgeAll DirGUTAge = 0
	DGUTAgeA1M DirGUTAge = 1
	DGUTAgeA2M DirGUTAge = 2
	DGUTAgeA6M DirGUTAge = 3
	DGUTAgeA1Y DirGUTAge = 4
	DGUTAgeA2Y DirGUTAge = 5
	DGUTAgeA3Y DirGUTAge = 6
	DGUTAgeA5Y DirGUTAge = 7
	DGUTAgeA7Y DirGUTAge = 8
	DGUTAgeM1M DirGUTAge = 9
	DGUTAgeM2M DirGUTAge = 10
	DGUTAgeM6M DirGUTAge = 11
	DGUTAgeM1Y DirGUTAge = 12
	DGUTAgeM2Y DirGUTAge = 13
	DGUTAgeM3Y DirGUTAge = 14
	DGUTAgeM5Y DirGUTAge = 15
	DGUTAgeM7Y DirGUTAge = 16
)

func AgeStringToDirGUTAge added in v5.1.0

func AgeStringToDirGUTAge(age string) (DirGUTAge, error)

AgeStringToDirGUTAge converts the String() representation of a DirGUTAge back in to a DirGUTAge. Errors if an invalid string supplied.

type DirGroupUserTypeAge added in v5.1.0

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

DirGroupUserTypeAge is used to summarise file stats by directory, group, user, file type and age.

func NewDirGroupUserTypeAge added in v5.1.0

func NewDirGroupUserTypeAge() *DirGroupUserTypeAge

NewDirGroupUserTypeAge returns a DirGroupUserTypeAge.

func (*DirGroupUserTypeAge) Add added in v5.1.0

func (d *DirGroupUserTypeAge) Add(path string, info fs.FileInfo) error

Add is a github.com/wtsi-ssg/wrstat/stat Operation. It will break path in to its directories and add the file size, increment the file count to each, summed for the info's group, user, filetype and age. It will also record the oldest file access time for each directory, plus the newest modification time.

If path is a directory, its access time is treated as now, so that when interested in files that haven't been accessed in a long time, directories that haven't been manually visted in a longer time don't hide the "real" results.

"Access" times are actually considered to be the greatest of atime, mtime and unix epoch.

NB: the "temp" filetype is an extra filetype on top of the other normal filetypes, so if you sum all the filetypes to get information about a given directory+group+user combination, you should ignore "temp". Only count "temp" when it's the only type you're considering, or you'll count some files twice.

func (*DirGroupUserTypeAge) Output added in v5.1.0

func (d *DirGroupUserTypeAge) Output(output io.WriteCloser) error

Output will write summary information for all the paths previously added. The format is (tab separated):

directory gid uid filetype age filecount filesize atime mtime

Where atime is oldest access time in seconds since Unix epoch of any file nested within directory. mtime is similar, but the newest modification time.

age is one of our age ints:

	 0 = all ages
	 1 = older than one month according to atime
	 2 = older than two months according to atime
	 3 = older than six months according to atime
	 4 = older than one year according to atime
	 5 = older than two years according to atime
	 6 = older than three years according to atime
	 7 = older than five years according to atime
	 8 = older than seven years according to atime
	 9 = older than one month according to mtime
	10 = older than two months according to mtime
	11 = older than six months according to mtime
	12 = older than one year according to mtime
	13 = older than two years according to mtime
	14 = older than three years according to mtime
 15 = older than five years according to mtime
	16 = older than seven years according to mtime

directory, gid, uid, filetype and age are sorted. The sort on the columns is not numeric, but alphabetical. So gid 10 will come before gid 2.

filetype is one of our filetype ints:

 0 = other (not any of the others below)
 1 = temp (.tmp | temp suffix, or .tmp. | .temp. | tmp. | temp. prefix, or
           a directory in its path is named "tmp" or "temp")
 2 = vcf
 3 = vcf.gz
 4 = bcf
 5 = sam
 6 = bam
 7 = cram
 8 = fasta (.fa | .fasta suffix)
 9 = fastq (.fq | .fastq suffix)
10 = fastq.gz (.fq.gz | .fastq.gz suffix)
11 = ped/bed (.ped | .map | .bed | .bim | .fam suffix)
12 = compresed (.bzip2 | .gz | .tgz | .zip | .xz | .bgz suffix)
13 = text (.csv | .tsv | .txt | .text | .md | .dat | readme suffix)
14 = log (.log | .out | .o | .err | .e | .err | .oe suffix)

Returns an error on failure to write. output is closed on completion.

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type GUTAKey added in v5.3.0

type GUTAKey struct {
	GID, UID uint32
	FileType DirGUTAFileType
	Age      DirGUTAge
}

func (GUTAKey) String added in v5.3.0

func (g GUTAKey) String() string

type GroupUser

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

GroupUser is used to summarise file stats by group and user.

func NewByGroupUser

func NewByGroupUser() *GroupUser

NewByGroupUser returns a GroupUser.

func (*GroupUser) Add

func (g *GroupUser) Add(_ string, info fs.FileInfo) error

Add is a github.com/wtsi-ssg/wrstat/stat Operation. It will add the file size and increment the file count summed for the info's group and user. If path is a directory, it is ignored.

func (*GroupUser) Output

func (g *GroupUser) Output(output io.WriteCloser) error

Output will write summary information for all the paths previously added. The format is (tab separated):

group username filecount filesize

group and username are sorted, and there is a special username "all" to give total filecount and filesize for all users that wrote files in that group.

Returns an error on failure to write, or if username or group can't be determined from the uids and gids in the added file info. output is closed on completion.

type Usergroup

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

Usergroup is used to summarise file stats by user and group.

func NewByUserGroup

func NewByUserGroup() *Usergroup

NewByUserGroup returns a Usergroup.

func (*Usergroup) Add

func (u *Usergroup) Add(path string, info fs.FileInfo) error

Add is a github.com/wtsi-ssg/wrstat/stat Operation. It will break path in to its directories and add the file size and increment the file count to each, summed for the info's user and group. If path is a directory, it is ignored.

func (*Usergroup) Output

func (u *Usergroup) Output(output io.WriteCloser) error

Output will write summary information for all the paths previously added. The format is (tab separated):

username group directory filecount filesize

usernames, groups and directories are sorted.

Returns an error on failure to write, or if username or group can't be determined from the uids and gids in the added file info. output is closed on completion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL