Documentation ¶
Index ¶
- Constants
- Variables
- func CopyDir(srcDir, dstDir string) error
- func CopyFile(ctx context.Context, src, out string) error
- func CopyReaderWithMode(ctx context.Context, src io.Reader, mode fs.FileMode, out string) error
- func EnsureDir(path string, perm fs.FileMode) error
- func HashFile(h hash.Hash, path string) error
- func HashFileWithName(h hash.Hash, root, path string) error
- func HashFiles(h hash.Hash, root string) error
- func ModeOf(path string) (fs.FileMode, error)
- type Path
Constants ¶
const ModeUserRW = 0600 // rw-------
const ModeUserRWX = 0700 // rwx------
const ModeUserRWXGroupRX = 0750 // rwxr-x---
Variables ¶
var ErrInvalidInput = errors.New("invalid input")
var ErrMissingInput = errors.New("missing input")
var ErrUnsupportedFileType = errors.New("unsupported file type")
ErrUnsupportedFileType is returned when attempting to copy a file type that's not supported.
Functions ¶
func CopyDir ¶
CopyDir recursively copies a directory from 'srcDir' to 'dstDir', preserving soft links. All regular files will be hard copied. Note that file attributes are not preserved, so this should only be used when the folder contents are required in the original structure. This implementation is based on [1].
[1] https://github.com/moby/moby/blob/master/daemon/graphdriver/copy/copy.go
func CopyFile ¶ added in v0.1.2
CopyFile is a utility function for copying an 'io.Reader' to a new file created with the specified 'os.FileMode'.
func CopyReaderWithMode ¶ added in v0.1.2
CopyReaderWithMode is a utility function for copying an 'io.Reader' to a new file created with the specified 'os.FileMode'.
func EnsureDir ¶
EnsureDir verifies that the specified path exists, is a directory, and has the specified permission bits set.
func HashFileWithName ¶ added in v0.3.10
Types ¶
type Path ¶ added in v0.1.3
type Path string
Path is a string type that's expected to be a path.
func (Path) CheckIsDir ¶ added in v0.1.3
CheckIsDir verifies that the underlying path is a valid directory.
func (Path) CheckIsDirOrEmpty ¶ added in v0.1.3
CheckIsDirOrEmpty verifies that the underlying path is either empty or a valid directory.
func (Path) CheckIsFile ¶ added in v0.1.3
CheckIsFile verifies that the underlying path is a valid file.
func (Path) CheckIsFileOrEmpty ¶ added in v0.1.3
CheckIsFileOrEmpty verifies that the underlying path is either empty or a valid file.
func (Path) Dir ¶ added in v0.3.18
Dir creates a new 'Path' pointing to the directory of this 'Path'.