file

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZipPath

func IsZipPath(p string) bool

IsZipPath returns true if the path includes the zip separator byte, indicating it is within a zip file.

func ZipFilePath

func ZipFilePath(path string) (zipFilename, filename string)

func ZipFilename

func ZipFilename(zipFilename, filenameInZip string) string

func ZipPathDisplayName

func ZipPathDisplayName(path string) string

ZipPathDisplayName converts an zip path for display. It translates the zip file separator character into '/', since this character is also used for path separators within zip files. It returns the original provided path if it does not contain the zip file separator character.

Types

type FSHasher

type FSHasher struct{}

func (*FSHasher) MD5

func (h *FSHasher) MD5(src io.Reader) (string, error)

func (*FSHasher) OSHash

func (h *FSHasher) OSHash(src io.ReadSeeker, size int64) (string, error)

type FileBased

type FileBased interface {
	File() models.File
}

type Hasher

type Hasher interface {
	OSHash(src io.ReadSeeker, size int64) (string, error)
	MD5(src io.Reader) (string, error)
}

type Scanned

type Scanned struct {
	Old *models.File
	New *models.File
}

func (Scanned) ContentsChanged

func (s Scanned) ContentsChanged() bool

ContentsChanged returns true if both old and new files are present and the file content is different.

func (Scanned) FileUpdated

func (s Scanned) FileUpdated() bool

FileUpdated returns true if both old and new files are present and not equal.

type Scanner

type Scanner struct {
	Hasher Hasher

	CalculateMD5    bool
	CalculateOSHash bool
}

func (Scanner) ScanExisting

func (o Scanner) ScanExisting(existing FileBased, file SourceFile) (h *Scanned, err error)

func (Scanner) ScanNew

func (o Scanner) ScanNew(file SourceFile) (*models.File, error)

type SourceFile

type SourceFile interface {
	Open() (io.ReadCloser, error)
	Path() string
	FileInfo() fs.FileInfo
}

func FSFile

func FSFile(path string, info fs.FileInfo) SourceFile

func ZipFile

func ZipFile(zipPath string, zf *zip.File) SourceFile

Jump to

Keyboard shortcuts

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