waryio

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCopyOptions = CopyOptions{
	SourceFlags:        os.O_RDONLY | syscall.O_NOFOLLOW,
	SourceModePreserve: true,

	DestFlags: os.O_WRONLY | os.O_CREATE | os.O_TRUNC | syscall.O_NOFOLLOW,
	DestMode:  0o666,
}
View Source
var ErrFileChanged = errors.New("file changed")
View Source
var ErrIterExhausted = errors.New("iterator exhausted")

Functions

func Copy

func Copy(opts CopyOptions) (err error)

Copy creates an exact file copy. The operation fails if the source file is modified concurrently.

func EnsureRelDir

func EnsureRelDir(base, path string, perm os.FileMode) (string, error)

EnsureRelDir creates a directory if and only if it is a subdirectory of base. The base directory must exist. Path may be an absolute path.

On success the cleaned path to the created directory is returned.

If path does not resolve to a subdirectory of base the directory is not created and the function merely returns the path.

func MakeAvailableDir

func MakeAvailableDir(g StringIter) (string, error)

func RenameToAvailableName

func RenameToAvailableName(oldpath string, g StringIter) (string, error)

RenameToAvailableName attempts to rename oldpath to a path produced by g. The used destination path is returned.

func SameStat

func SameStat(a, b string) (bool, error)

SameStat checks whether two paths point to the same file.

Types

type CopyOptions

type CopyOptions struct {
	SourcePath         string
	SourceFlags        int
	SourceMode         os.FileMode
	SourceModePreserve bool

	DestPath  string
	DestFlags int
	DestMode  os.FileMode
	DestSync  bool
}

type FileChanges

type FileChanges []string

func DescribeChanges

func DescribeChanges(a, b os.FileInfo) FileChanges

DescribeChanges produces a list of changes detected between the two given FileInfo instances.

func (FileChanges) Empty

func (c FileChanges) Empty() bool

func (FileChanges) Err

func (c FileChanges) Err() error

type StringIter

type StringIter interface {
	Next() (string, bool)
}

Jump to

Keyboard shortcuts

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