Documentation
¶
Index ¶
- func CalcCheckSum(b []byte) string
- type Safe
- func (s *Safe) AddBytes(cnt int64)
- func (s *Safe) AddLine()
- func (s *Safe) Checksum() string
- func (s *Safe) Created() string
- func (s *Safe) IsDir() bool
- func (s *Safe) JSONBytes() []byte
- func (s *Safe) JSONString() string
- func (s *Safe) ParseCreated() time.Time
- func (s *Safe) Path() string
- func (s *Safe) SetChecksum(hsh hash.Hash)
- func (s *Safe) SetCreated(t time.Time)
- func (s *Safe) SetDir(isDir bool)
- func (s *Safe) SetPath(pth string)
- func (s *Safe) SetSize(size int64)
- func (s *Safe) Stats() Stats
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcCheckSum ¶ added in v0.30.0
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
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) JSONString ¶ added in v0.30.0
func (*Safe) ParseCreated ¶ added in v0.30.0
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) SetChecksum ¶ added in v0.30.0
SetChecksum will correctly calculate and set the base64 encoded checksum.
func (*Safe) SetCreated ¶ added in v0.30.0
SetCreated will set the Created field in the format time.RFC3339 in UTC.
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 NewFromBytes ¶
NewFromBytes creates Stats from json bytes.
func NewFromInfo ¶
NewFromInfo creates Stats from a uri formatted info string.
func (Stats) JSONString ¶
func (Stats) ParseCreated ¶
ParseCreated converts the store string timestamp to a time.Time value