stat

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 7 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcCheckSum added in v0.30.0

func CalcCheckSum(b []byte) string

CalcCheckSum creates a md5 hash based on the bytes passed in. This is a common method to get a checksum of a file.

Types

type Safe added in v0.30.0

type Safe struct {
	// LineCnt returns the file line count.
	LineCnt int64 `json:"linecnt,omitempty"`

	// ByteCount returns uncompressed raw file byte count.
	ByteCnt int64 `json:"bytecnt,omitempty"`

	// Size holds the actual file size.
	Size int64 `json:"size"`

	Files int64 `json:"files,omitempty"`
	// contains filtered or unexported fields
}

Safe is thread safe without using mutex by using atomic values for all fields Do not directly modify on the values in this struct.

func (*Safe) AddBytes added in v0.30.0

func (s *Safe) AddBytes(cnt int64)

AddBytes will atomically and safely increment ByteCnt by 'cnt'.

func (*Safe) AddLine added in v0.30.0

func (s *Safe) AddLine()

AddLine will atomically and safely increment LineCnt by one.

func (*Safe) Checksum added in v0.30.0

func (s *Safe) Checksum() string

func (*Safe) Created added in v0.30.0

func (s *Safe) Created() string

func (*Safe) IsDir added in v0.30.0

func (s *Safe) IsDir() bool

func (*Safe) JSONBytes added in v0.30.0

func (s *Safe) JSONBytes() []byte

func (*Safe) JSONString added in v0.30.0

func (s *Safe) JSONString() string

func (*Safe) ParseCreated added in v0.30.0

func (s *Safe) ParseCreated() time.Time

ParseCreated will attempt to parse the Created field to a time.Time object. ParseCreated expects the Created time string is in time.RFC3339. If there is a parse error then the time.Time zero value is returned.

The returned time will always be in UTC.

func (*Safe) Path added in v0.30.0

func (s *Safe) Path() string

func (*Safe) SetChecksum added in v0.30.0

func (s *Safe) SetChecksum(hsh hash.Hash)

SetChecksum will correctly calculate and set the base64 encoded checksum.

func (*Safe) SetCreated added in v0.30.0

func (s *Safe) SetCreated(t time.Time)

SetCreated will set the Created field in the format time.RFC3339 in UTC.

func (*Safe) SetDir added in v0.30.0

func (s *Safe) SetDir(isDir bool)

func (*Safe) SetPath added in v0.30.0

func (s *Safe) SetPath(pth string)

func (*Safe) SetSize added in v0.30.0

func (s *Safe) SetSize(size int64)

func (*Safe) Stats added in v0.30.0

func (s *Safe) Stats() Stats

type Stats

type Stats struct {
	LineCnt int64 `json:"linecnt,omitempty"`

	// ByteCount returns uncompressed raw file byte count.
	ByteCnt int64 `json:"bytecnt,omitempty"`

	// Size holds the actual file size.
	Size int64 `json:"size"`

	// Checksum base64 encoded string of the file md5 hash
	Checksum string `json:"checksum,omitempty"`

	// Path returns the full absolute path of the file.
	Path string `json:"path" uri:"origin"`

	// Created date the file was created or last updated Format(time.RFC3339)
	// whichever is more recent.
	Created string `json:"created"`

	IsDir bool `json:"isDir,omitempty"`

	Files int64 `json:"files,omitempty"`
}

Stats is an immutable struct describe file details Safe should be used for any needed changes

func New deprecated

func New() Stats

Deprecated: reference Stats directly stat.Stats{}

func NewFromBytes

func NewFromBytes(b []byte) (sts Stats)

NewFromBytes creates Stats from json bytes.

func NewFromInfo

func NewFromInfo(info string) (sts Stats)

NewFromInfo creates Stats from a uri formatted info string.

func (Stats) JSONBytes

func (s Stats) JSONBytes() []byte

func (Stats) JSONString

func (s Stats) JSONString() string

func (Stats) ParseCreated

func (s Stats) ParseCreated() time.Time

ParseCreated converts the store string timestamp to a time.Time value

func (Stats) ToSafe added in v0.30.0

func (s Stats) ToSafe() *Safe

Jump to

Keyboard shortcuts

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