validfile

package
v0.0.0-...-080ad10 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirExists

func DirExists(name string) (exists bool, err error)

DirExists uses TryStat function to check if the directory exists at location.

If stat fails with error related to directory absence, it does not return that error, only false boolean; in any other case both false and the error are returned.

If stat succeeds, only true boolean is returned.

func FileExists

func FileExists(name string) (exists bool, err error)

FileExists uses TryStat function to check if the file exists at location.

If stat fails with error related to file absence, it does not return that error, only false boolean; in any other case both false and the error are returned.

If stat succeeds, only true boolean is returned.

func NotExpired

func NotExpired(name string, ttl time.Duration) error

func PathExists

func PathExists(name string) (exists bool, err error)

PathExists uses TryStat function to check if the file or directory exists at location.

If stat fails with error related to file or directory absence, it does not return that error, only false boolean; in any other case both false and the error are returned.

If stat succeeds, only true boolean is returned.

func TryStat

func TryStat(name string) (stat os.FileInfo, err error)

func ValidateExistsFile

func ValidateExistsFile(name string) (err error)

func ValidateFile

func ValidateFile(name string, hash hash.Hash, expected []byte) error

func ValidateFileHex

func ValidateFileHex(name string, hash hash.Hash, expected string) error

Types

type FileExpiredError

type FileExpiredError struct {
	Name     string
	Modified time.Time
	TTL      time.Duration
}

func (*FileExpiredError) Error

func (e *FileExpiredError) Error() string

func (*FileExpiredError) Is

func (e *FileExpiredError) Is(target error) bool

type HashMatchError

type HashMatchError struct {
	Expected []byte
	Actual   []byte
}

func (*HashMatchError) Error

func (h *HashMatchError) Error() string

func (*HashMatchError) Is

func (h *HashMatchError) Is(target error) bool

type InvalidHashSumError

type InvalidHashSumError struct {
	Sum []byte
	Err error
}

func (*InvalidHashSumError) Error

func (i *InvalidHashSumError) Error() string

func (*InvalidHashSumError) Is

func (i *InvalidHashSumError) Is(target error) bool

func (*InvalidHashSumError) Unwrap

func (i *InvalidHashSumError) Unwrap() error

type StatErr

type StatErr struct {
	Name string
	Err  error
}

func (*StatErr) DoesNotExist

func (s *StatErr) DoesNotExist() bool

DoesNotExist returns whether the error is related to file being absent rather than any other reason.

func (*StatErr) Error

func (s *StatErr) Error() string

func (*StatErr) Is

func (s *StatErr) Is(target error) bool

func (*StatErr) Unwrap

func (s *StatErr) Unwrap() error

type ValidateError

type ValidateError struct {
	Name string
	Err  error
}

func (*ValidateError) Error

func (v *ValidateError) Error() string

func (*ValidateError) Is

func (v *ValidateError) Is(target error) bool

func (*ValidateError) Mismatch

func (v *ValidateError) Mismatch() bool

Mismatch returns whether the error is just about mismatch. This value will be true if file does not exist, or if it does, but hash does not match. In any other case, the value is false.

func (*ValidateError) Unwrap

func (v *ValidateError) Unwrap() error

type WrongPathType

type WrongPathType struct {
	Name        string
	IsDirectory bool
}

func (*WrongPathType) Error

func (f *WrongPathType) Error() string

func (*WrongPathType) Is

func (f *WrongPathType) Is(target error) bool

Jump to

Keyboard shortcuts

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