file

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDirectory = errors.New("target is not a directory")

Functions

func SetFS

func SetFS(FS afero.Fs)

Types

type Converter

type Converter interface {
	Convert(Info) (string, error)
	SetNext(Converter)
}

func NewJpeg2JpgConverter

func NewJpeg2JpgConverter() Converter

func NewMD5Converter

func NewMD5Converter() Converter

func NewSHA1Converter

func NewSHA1Converter() Converter

func NewToLowerConverter

func NewToLowerConverter() Converter

func NewToUpperConverter

func NewToUpperConverter() Converter

type CopyTarget

type CopyTarget struct {
	Path string
}

CopyTarget creates a copy of original file with a new name.

func (*CopyTarget) Acquire

func (t *CopyTarget) Acquire(info Info, newName string) error

type Info

type Info interface {
	Name() string
	Path() string
}

type MD5Producer

type MD5Producer struct {
}

func (MD5Producer) Produce

func (p MD5Producer) Produce(reader io.Reader) (string, error)

type MoveTarget

type MoveTarget struct {
	Path string
}

MoveTarget renames original files into new ones.

func (*MoveTarget) Acquire

func (t *MoveTarget) Acquire(info Info, newName string) error

type ReaderProducer

type ReaderProducer interface {
	Produce(io.Reader) (string, error)
}

type SHA1Producer

type SHA1Producer struct {
}

func (SHA1Producer) Produce

func (p SHA1Producer) Produce(reader io.Reader) (string, error)

type Source

type Source interface {
	GetFiles() ([]Info, error)
}

func NewSource

func NewSource(path string) Source

NewSource instantiates a new Source.

type Target

type Target interface {
	// Acquire receives a file with a new name into target.
	Acquire(info Info, newName string) error
}

Target represents destination directory, where files with new names must be placed.

func CreateCopyTarget

func CreateCopyTarget(path string) (Target, error)

CreateCopyTarget instantiates new CopyTarget object, creating destination directory if it does not exist.

func CreateMoveTarget

func CreateMoveTarget(path string) (Target, error)

CreateMoveTarget instantiates new MoveTarget object, creating destination directory if it does not exist.

func NewVoidTarget

func NewVoidTarget() Target

type VoidTarget

type VoidTarget struct {
}

VoidTarget does not perform any actions on files. Suitable for DryRun mode

func (*VoidTarget) Acquire

func (t *VoidTarget) Acquire(_ Info, _ string) error

Jump to

Keyboard shortcuts

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