filesystem

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: MIT Imports: 13 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOutsideRepo is returned when the target file is outside of the repository
	ErrOutsideRepo = errors.New("target file outside repository")
)

Functions

func EvaluateFilePath

func EvaluateFilePath(repository, urlpath string) (string, error)

EvaluateFilePath sanitize and validate the file against the local repository

func IsInRepository

func IsInRepository(repository, filePath string) bool

IsInRepository ensures that the given file path is contained in the repository

func Sha256sum

func Sha256sum(path string) ([]byte, error)

Sha256sum generates a human readable sha256 hash of the given file path

Types

type FileInfo

type FileInfo struct {
	Path    string    `redis:"-"`
	Size    int64     `redis:"size" json:",omitempty"`
	ModTime time.Time `redis:"modTime" json:",omitempty"`
	Sha1    string    `redis:"sha1" json:",omitempty"`
	Sha256  string    `redis:"sha256" json:",omitempty"`
	Md5     string    `redis:"md5" json:",omitempty"`
}

FileInfo is a struct embedding details about a file served by the redirector.

func HashFile

func HashFile(path string) (hashes FileInfo, err error)

HashFile generates a human readable hash of the given file path

func NewFileInfo

func NewFileInfo(path string) FileInfo

NewFileInfo returns a new FileInfo object

Jump to

Keyboard shortcuts

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