scan

package
v0.0.0-...-a7a482b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonDirStats

type CommonDirStats struct {
	// Size is the total size of children, in bytes.
	Size int64 `json:"s"`
	// Files is the number of child regular files.
	Files int `json:"fc"`
	// Directories is the number of child directories.
	Directories int `json:"dc"`
	// Extensions is the size and number of children, grouped by file extension.
	Extensions map[string]*CountSize `json:"e"`
	// ModificationYears is the size and number of children, grouped by modification year.
	ModificationYears map[int]*CountSize `json:"y"`
}

CommonDirStats are common statistics between direct and recursive directory statistics.

type CountSize

type CountSize struct {
	// Count is the number of files.
	Count int `json:"fc"`
	// Size the size of files, in bytes.
	Size int64 `json:"s"`
}

CountSize indicates a number of files and a size, in bytes.

type DateTime

type DateTime time.Time

DateTime is the time structure with a custom marshal format.

func (DateTime) MarshalJSON

func (t DateTime) MarshalJSON() ([]byte, error)

MarshalJSON marshals the time with the RFC3339 format.

func (DateTime) Year

func (t DateTime) Year() int

Year returns the year in which t occurs.

type DirectStats

type DirectStats struct {
	CommonDirStats
	// Children is the list of direct child files indexes.
	Children []int `json:"c"`
}

DirectStats are directory statistics about direct child files.

type FileStat

type FileStat struct {
	// Path is the path to the file (absolute for the root directory, relative for other).
	Path string `json:"p"`
	// Name is the name of the file.
	Name string `json:"n"`
	// Extension is the extension part of the file name, including the leading dot.
	Extension string `json:"e"`
	// Type is the type of the file (regular file or directory).
	Type string `json:"t"`
	// Size is the size of the file, in bytes.
	Size int64 `json:"s"`
	// LastWriteTime is the time the current file was last written (contents changed).
	LastWriteTime DateTime `json:"m"`
	// Direct is the statistics object about direct child files.
	Direct *DirectStats `json:"d,omitempty"`
	// Recursive is the statistics object about direct and indirect child files.
	Recursive *RecursiveStats `json:"r,omitempty"`
}

FileStat stores basic information and statistics about a file.

func NewDirectoryStat

func NewDirectoryStat(path string, info fs.FileInfo) (stat *FileStat)

NewDirectoryStat creates a new file statistics object for a directory.

func NewFileStat

func NewFileStat(path string, info fs.FileInfo) *FileStat

NewFileStat creates a new file statistics object for a regular file.

func Scan

func Scan(dir string) (files []*FileStat, err error)

Scan lists all files and directories in the given directory and collect statistics.

func (*FileStat) Ext

func (stat *FileStat) Ext() string

Ext returns the file extension (without the dot) if it is short (<= 15 chars).

type Range

type Range struct {
	// Start is the start index (inclusive).
	Start int `json:"s"`
	// End is the end index (exclusive).
	End int `json:"e"`
}

Range is a range of item indexes.

type RecursiveStats

type RecursiveStats struct {
	CommonDirStats
	// Depth is the maximum level of nesting in the current directory.
	Depth int `json:"d"`
	// Children is the range of direct and indirect child files.
	Children Range `json:"c"`
}

RecursiveStats are directory statistics about direct and indirect child files.

Jump to

Keyboard shortcuts

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