file

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Copy file from source to destination by chunks of 32KB.
	Copy(srcPath, dstPath string, targetPerm os.FileMode) error
	// Delete deletes file. If there is an error, it will be of types *os.PathError.
	Delete(filepath string) error
	// Checksum validates a file from given path.
	// Returns error only if it cannot read or locate the file, or the checksum failed.
	Checksum(filepath string, checksum string) error
	// Fetch will retrieve file from given uri
	Fetch(uri string, filepath string) error
	// FetchAndCheck calls Fetch to retrieve file, while checking the checksum to validate incoming file.
	// The file will be deleted if checksum fails.
	FetchAndCheck(uri string, filepath string, checksum string) error
	// Write writes byte array content to given filepath and permission.
	Write(filepath string, content []byte, perm os.FileMode) error
	// Read reads byte array content from given filepath. This works as identical delegation to os.ReadFile.
	Read(filepath string) ([]byte, error)
	// Exists checks filepath to see if exists
	Exists(filepath string) (bool, error)
}

func NewHandler

func NewHandler() Handler

type Reader

type Reader interface {
	ReadFile(path string) ([]byte, error)
	Exists(path string) (bool, error)
}

Jump to

Keyboard shortcuts

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