filecopy

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(destPath string, srcPath string) error

Copy copies a source file to a destination file. File contents are copied. File mode and permissions (as described in http://golang.org/pkg/os/#FileMode) are copied.

Directories are copied, along with their contents.

Copying a file or directory to itself succeeds but does not modify the filesystem.

Symbolic links are not followed and are copied provided they refer to a file or directory being copied (otherwise a non-nil error is returned). The only exception is copying a symbolic link to itself, which always succeeds.

func NewChecker

func NewChecker() *checker

func NewCopier

func NewCopier(log io.Writer, checker Checker) *copier

Types

type Checker

type Checker interface {
	/*
		Tests the existence of a file or directory at a given path. Returns true if and only if the file or
		directory exists.
	*/
	Exists(path string) bool

	/*
		Filemode returns the os.FileMode of the file with the given path. If the file does not exist, returns
		an error with tag ErrFileNotFound.
	*/
	Filemode(path string) (os.FileMode, error)
}

Checker is a helper interface for querying files and directories.

type Copier

type Copier interface {
	/*
		Copy copies a source file to a destination file. File contents are copied. File mode and permissions
		(as described in http://golang.org/pkg/os/#FileMode) are copied.

		Directories are copied, along with their contents.

		Copying a file or directory to itself succeeds but does not modify the filesystem.

		Symbolic links are not followed and are copied provided they refer to a file or directory being copied
		(otherwise a non-nil error is returned). The only exception is copying a symbolic link to itself, which
		always succeeds.
	*/
	Copy(destPath string, srcPath string) error
}

Copier is a helper interface for copying files and/or directories.

type ErrorId

type ErrorId string
const (
	ErrOpeningSourceDir     ErrorId = "cannot open source directory"
	ErrCannotListSourceDir  ErrorId = "cannot list source directory"
	ErrUnexpected           ErrorId = "unexpected error"
	ErrCreatingTargetDir    ErrorId = "cannot create target directory"
	ErrOpeningSourceFile    ErrorId = "cannot open source file"
	ErrOpeningTargetFile    ErrorId = "cannot open target file"
	ErrCopyingFile          ErrorId = "file copy failed"
	ErrReadingSourceSymlink ErrorId = "cannot read symbolic link source"
	ErrWritingTargetSymlink ErrorId = "cannot write target symbolic link"
	ErrExternalSymlink      ErrorId = "external symbolic link"
)
const ErrFileNotFound ErrorId = "file not found"

type FileError

type FileError struct {
	ErrorId ErrorId
	Cause   error
}

func (FileError) Error

func (fe FileError) Error() string

Jump to

Keyboard shortcuts

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