paths

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(source, target <-chan Metadata, forceModified bool, callback func(DiffChange) error) (int, error)

Diff compares two sources of Metadata and report the file changes, using the file modification date.

Returns the number of files in the source.

Warning: The Metadata have to be sorted by their Path for the diffing to work properly.

func DirExists

func DirExists(path string) (bool, error)

DirExists returns whether the given path exists and is a directory.

func DropExt

func DropExt(path string) string

DropExt returns the path after removing any file extension.

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given path exists on the file system.

func FilenameStem

func FilenameStem(path string) string

FilenameStem returns the filename component of the given path, after removing its file extension.

func Walk

func Walk(basePath string, logger util.Logger, shouldIgnorePath func(string) (bool, error)) <-chan Metadata

Walk emits the metadata of each file stored in the directory if they pass the given shouldIgnorePath closure. Hidden files and directories are ignored.

func WriteString

func WriteString(path string, content string) error

WriteString writes the given content into a new file at the given path, creating any intermediate directories if needed.

Types

type DiffChange

type DiffChange struct {
	Path string
	Kind DiffKind
}

DiffChange represents a file change made in a directory.

func (DiffChange) String

func (c DiffChange) String() string

String implements Stringer.

type DiffKind

type DiffKind int

DiffKind represents a type of file change made in a directory.

const (
	DiffAdded DiffKind = iota + 1
	DiffModified
	DiffRemoved
	DiffUnchanged
)

func (DiffKind) String

func (k DiffKind) String() string

String implements Stringer.

func (DiffKind) Symbol added in v0.8.0

func (k DiffKind) Symbol() string

Symbol returns a single character symbol representing this change.

type Metadata

type Metadata struct {
	Path     string
	Modified time.Time
}

Metadata holds information about a file path.

Jump to

Keyboard shortcuts

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