Documentation
¶
Index ¶
- func CheckPathExists(chkPath string) bool
- func CompressGZIP(data []byte) (compressedData []byte, err error)
- func CompressWhenNeeded(data []byte) (resultData []byte, compression *string, err error)
- func DecompressGZIP(compressedData []byte) (decompressedData []byte, err error)
- func DecompressWhenNeeded(data []byte, compression sql.NullString) (resultData []byte, err error)
- func GetMd5Hash(target any) (hashed string, err error)
- func GetSha256Hash(target any) (hashed string, err error)
- func GetSha512Hash(target any) (hashed string, err error)
- func HumanReadableSize(data []byte) string
- type FileManager
- type ManagedFile
- func (fm *ManagedFile) Accessible() (accessible bool, err error)
- func (fm *ManagedFile) Backup() (err error)
- func (fm *ManagedFile) BackupsEnabled() bool
- func (fm *ManagedFile) Close() (err error)
- func (fm *ManagedFile) Create() (err error)
- func (fm *ManagedFile) Delete() (err error)
- func (fm *ManagedFile) DisableBackups()
- func (fm *ManagedFile) EnableBackups()
- func (fm *ManagedFile) Exists() (exists bool, err error)
- func (fm *ManagedFile) Group() string
- func (fm *ManagedFile) Init(filePath, user, group string, perm os.FileMode) (err error)
- func (fm *ManagedFile) IsLocked() bool
- func (fm *ManagedFile) Lock() (err error)
- func (fm *ManagedFile) Open(create bool) (err error)
- func (fm *ManagedFile) Path() string
- func (fm *ManagedFile) Perm() os.FileMode
- func (fm *ManagedFile) Read() (content []byte, err error)
- func (fm *ManagedFile) SetGroup(group string) (err error)
- func (fm *ManagedFile) SetPath(path string) (err error)
- func (fm *ManagedFile) SetPerm(perm os.FileMode) (err error)
- func (fm *ManagedFile) SetUser(user string) (err error)
- func (fm *ManagedFile) Unlock() (err error)
- func (fm *ManagedFile) Update(updatedContent []byte) (err error)
- func (fm *ManagedFile) UseExistingFile(path string) (err error)
- func (fm *ManagedFile) User() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPathExists ¶
func CompressGZIP ¶
func CompressWhenNeeded ¶
TODO: check if it's worth trying to compress the data prior to compressing it (e.g: using entropy algorithms) This would save some CPU usage client side TODO: have telemetry data type be passed in as a parameter to further check if we should compress data and which algorithm to use (e.g: deflate or gzip)
func DecompressGZIP ¶
func DecompressWhenNeeded ¶
func DecompressWhenNeeded(data []byte, compression sql.NullString) (resultData []byte, err error)
TODO: have telemetry data type be passed in as a parameter to further check if we should decompress data and which algorithm to use (e.g: deflate or gzip)
func GetMd5Hash ¶
func GetSha256Hash ¶
func GetSha512Hash ¶
func HumanReadableSize ¶
Types ¶
type FileManager ¶
type FileManager interface {
// init a new file manager
Init(filePath string, owner string, group string, perm os.FileMode) error
// init from an existing file
UseExistingFile(filePath string) error
// backups management
EnableBackups()
DisableBackups()
BackupsEnabled() bool
// file path
Path() string
SetPath(filePath string) error
Exists() (bool, error)
Accessible() (bool, error)
// file ownership and permissions
User() string
SetUser(string) error
Group() string
SetGroup(string) error
Perm() os.FileMode
SetPerm(perm os.FileMode) error
// lock management
Lock() error
Unlock() error
IsLocked() bool
// data operations
Open(create bool) error
Create() error
Read() ([]byte, error)
Update(updatedContent []byte) error
Backup() error
Delete() error
Close() error
}
FileManager interface
type ManagedFile ¶
type ManagedFile struct {
// contains filtered or unexported fields
}
ManagedFile
func NewManagedFile ¶
func NewManagedFile() *ManagedFile
func (*ManagedFile) Accessible ¶ added in v0.1.2
func (fm *ManagedFile) Accessible() (accessible bool, err error)
func (*ManagedFile) Backup ¶
func (fm *ManagedFile) Backup() (err error)
func (*ManagedFile) BackupsEnabled ¶
func (fm *ManagedFile) BackupsEnabled() bool
func (*ManagedFile) Close ¶
func (fm *ManagedFile) Close() (err error)
func (*ManagedFile) Create ¶
func (fm *ManagedFile) Create() (err error)
func (*ManagedFile) Delete ¶
func (fm *ManagedFile) Delete() (err error)
func (*ManagedFile) DisableBackups ¶
func (fm *ManagedFile) DisableBackups()
func (*ManagedFile) EnableBackups ¶
func (fm *ManagedFile) EnableBackups()
func (*ManagedFile) Exists ¶
func (fm *ManagedFile) Exists() (exists bool, err error)
func (*ManagedFile) Group ¶
func (fm *ManagedFile) Group() string
func (*ManagedFile) Init ¶
func (fm *ManagedFile) Init(filePath, user, group string, perm os.FileMode) (err error)
func (*ManagedFile) IsLocked ¶
func (fm *ManagedFile) IsLocked() bool
func (*ManagedFile) Lock ¶
func (fm *ManagedFile) Lock() (err error)
func (*ManagedFile) Open ¶
func (fm *ManagedFile) Open(create bool) (err error)
func (*ManagedFile) Path ¶
func (fm *ManagedFile) Path() string
func (*ManagedFile) Perm ¶
func (fm *ManagedFile) Perm() os.FileMode
func (*ManagedFile) Read ¶
func (fm *ManagedFile) Read() (content []byte, err error)
func (*ManagedFile) SetGroup ¶
func (fm *ManagedFile) SetGroup(group string) (err error)
func (*ManagedFile) SetPath ¶
func (fm *ManagedFile) SetPath(path string) (err error)
func (*ManagedFile) SetUser ¶
func (fm *ManagedFile) SetUser(user string) (err error)
func (*ManagedFile) Unlock ¶
func (fm *ManagedFile) Unlock() (err error)
func (*ManagedFile) Update ¶
func (fm *ManagedFile) Update(updatedContent []byte) (err error)
func (*ManagedFile) UseExistingFile ¶
func (fm *ManagedFile) UseExistingFile(path string) (err error)
func (*ManagedFile) User ¶
func (fm *ManagedFile) User() string
Click to show internal directories.
Click to hide internal directories.