Documentation
¶
Overview ¶
Package filework provides file system abstraction and operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExistingDirectory is returned when a directory is found where a file // was expected. ErrExistingDirectory = errors.New("a directory exists where a file was expected") // ErrExistingFile is returned when a file is found where a directory // was expected. ErrExistingFile = errors.New("a file exists where a directory was expected") // ErrBadDirectory is returned when a file is found where a directory // was expected. ErrBadDirectory = errors.New("a file does not implement the directory interface despite being marked as a directory") )
Functions ¶
Types ¶
type Comparison ¶
type Comparison int
Comparison describes the difference between two files.
const ( Different Comparison = 0 Missing Comparison = 1 Same Comparison = 2 )
Comparison constants.
func CompareFileContent ¶
func CompareFileContent(content io.Reader, fs FileSystem, path string) (Comparison, error)
CompareFileContent compares content with a destination file system.
If content implements io.Seeker, a seek to the start of content will be performed before and after a comparison is performed. NOTE: This behavior is subject to change in future revisions.
func (Comparison) String ¶
func (c Comparison) String() string
String returns a string representation of the comparison.
type FileSystem ¶
type FileSystem interface {
Open(name string) (File, error)
Stat(name string) (os.FileInfo, error)
}
FileSystem is the minimum interface required to read from a file system.
type FileSystemWriter ¶
type FileSystemWriter interface {
FileSystem
Create(name string) (FileWriter, error)
Remove(path string) error
RemoveAll(path string) error
MkdirAll(path string, perm os.FileMode) error
}
FileSystemWriter is the minimum interface required to write to a file system.
type FileWriter ¶
FileWriter is the minimum interface required to write files.
type Log ¶
type Log []Result
A Log is a set of file copy results.
func CopyDir ¶
func CopyDir(sourceFS FileSystem, sourcePath string, source Dir, destFS FileSystemWriter, destPath string, destPerms os.FileMode) (lg Log)
CopyDir copies a directory and all of its contents.
TODO: Determine content copying by option? TODO: Determine perms by option?
TODO: Receive a context?
func CopyPath ¶
func CopyPath(sourceFS FileSystem, sourcePath string, destFS FileSystemWriter, destPath string) (lg Log)
CopyPath copies a file or directory described by path from source to dest and returns a log of its actions.
TODO: Allow the user to specify perms for directories?
type Namer ¶
type Namer interface {
Name() string
}
A Namer is a file capable of reporting its name.
type Op ¶
type Op uint32
Op is a filework operation.
const (
CopyOperation Op = 1
)
Filework operations.
type Outcome ¶
type Outcome int
Outcome holds the outcome of an attempted action on a file or set of files.
Outcome constants.
func CopyFileContent ¶
CopyFileContent copies data from content to fs and reports the outcome.
type Result ¶
Result is the result of a filework operation.
func CopyFile ¶
func CopyFile(sourceFS FileSystem, sourcePath string, source File, destFS FileSystemWriter, destPath string) Result
CopyFile copies data from source to dest.