Documentation
¶
Index ¶
- Variables
- func Access(path string, mode uint32) bool
- func ArchiveRootDirs(archive string) (map[string]bool, error)
- func AtomicReplace(tmp, target string) (string, error)
- func AtomicWrite(ctx context.Context, path string, write func(*os.File) error, o WriteOptions) error
- func AtomicWriteBytes(ctx context.Context, path string, content []byte, prefix string, ...) error
- func AtomicWriteText(ctx context.Context, path, content, prefix string) error
- func AtomicWriteTextMode(ctx context.Context, path, content, prefix string, mode os.FileMode) error
- func AtomicWriteTextWith(ctx context.Context, path, content string, o TextWrite) error
- func CloseTempDir(name string, errp *error)
- func Copy2(src, dst string) error
- func CopyRegularFiles(src, dst string) (int, error)
- func CopyTree(src, dst string, symlinks, dirsExistOK bool, ignore IgnoreFunc) error
- func CopyTreeAbortable(src, dst string, symlinks, dirsExistOK bool, ignore IgnoreErrFunc) error
- func DiskUsage(path string) (total, used, free uint64, err error)
- func ExtractTarDataReader(f io.Reader, destination string) error
- func Filemode(mode uint32) string
- func HolderFileLock(lockPath string, holder *LockHolder, timeout time.Duration, ...) (func(), error)
- func IsContendedReplaceError(err error) bool
- func IsCrossDeviceError(err error) bool
- func LockFile(f *os.File) error
- func LockHolderHint(lockPath string) string
- func LstatIdentity(path string) (dev, ino uint64, err error)
- func MakeTargz(base, rootDir, baseDir string) (string, error)
- func Makedirs(name string, mode os.FileMode, existOK bool) error
- func MkstempBeside(target, prefix, suffix string) (*os.File, error)
- func ModeForWrite(path string, createMode uint32, createSet, preserve bool) (uint32, bool)
- func Move(src, dst string) (string, error)
- func NormalizeArchiveParts(member string) ([]string, error)
- func OSErrorText(err error) string
- func PlatformNewlines(s string) string
- func PosixModeBits(m os.FileMode) uint32
- func PreserveFileMode(path string) (uint32, bool)
- func ReadTextChars(path string, n int, sig bool) (string, error)
- func RemoveTempDir(name string) error
- func RestoreFileMode(path string, mode uint32, ok bool)
- func RestoreFileOwner(path string, owner *FileOwner)
- func RmTree(path string, onexc func(op RmTreeOp, path string, err error) error) error
- func SafeExtractTargz(archive, destination string) error
- func TarMemberNames(r io.Reader) ([]string, error)
- func TryLockFile(f *os.File) (bool, error)
- func UnlinkFilesOlderThan(dir, pattern string, maxAgeSeconds float64, now *float64) int
- func UnlockFile(f *os.File) error
- func Walk(top string, followlinks bool, ...)
- type ArchiveError
- type CopyTreeError
- type EncodeError
- type FileOwner
- type IgnoreErrFunc
- type IgnoreFunc
- type LockHolder
- type LockTimeoutError
- type MoveError
- type MovePermissionError
- type RmTreeOp
- type TarAdder
- type TarFilterError
- type TextWrite
- type UnicodeDecodeError
- type WriteOptions
Constants ¶
This section is empty.
Variables ¶
var ErrRmTreeSymlink = errors.New("Cannot call rmtree on a symbolic link")
Error rmtree raises for a symlinked root or a symlinked subdirectory that reports as a directory
var Fsync = func(f *os.File) error { return f.Sync() }
File flush every atomic writer runs before the replace, the os.fsync tests fail
var FsyncDirectory = fsyncDirectory
Directory flush every durable write calls, the name a case replaces the way pytest patches utils.fsync_directory
Functions ¶
func Access ¶
Whether the real user may open path with every R_OK, W_OK and X_OK bit of mode, as os.access answers
func ArchiveRootDirs ¶
Top level directory names of an archive, counting a root only through a nested member or a directory member
func AtomicReplace ¶
Moves tmp onto target keeping a symlink target in place, returning the path actually written
func AtomicWrite ¶
func AtomicWrite(ctx context.Context, path string, write func(*os.File) error, o WriteOptions) error
Temp file beside the target, fsync and atomic replace with owner and mode reapplied, the temp removed on failure
func AtomicWriteBytes ¶
func AtomicWriteBytes(ctx context.Context, path string, content []byte, prefix string, mode *os.FileMode, fsyncDir bool) error
Writes bytes through a fsynced temp sibling and an atomic rename, mode nil keeping an existing file mode
func AtomicWriteText ¶
Writes text through a temp file beside the published target, fsync, and an atomic rename
func AtomicWriteTextMode ¶
Writes like AtomicWriteText with the permission bits forced
func AtomicWriteTextWith ¶
Writes utf-8 text through the shared atomic writer under the given keyword arguments
func CloseTempDir ¶
Cleans up a temporary directory at the end of its with block, a cleanup error replacing the block result
func Copy2 ¶
shutil.copy2 into dst or into dst when it is a directory, content, mode, both times and xattrs
func CopyRegularFiles ¶
Copies the regular files under src into dst skipping symlinks, returning the count
func CopyTree ¶
func CopyTree(src, dst string, symlinks, dirsExistOK bool, ignore IgnoreFunc) error
Copies a directory tree the way shutil.copytree does with copy2, failures gathered into one error
func CopyTreeAbortable ¶
func CopyTreeAbortable(src, dst string, symlinks, dirsExistOK bool, ignore IgnoreErrFunc) error
Tree copy whose ignore callback raising stops the copy at once and returns that error unchanged
func DiskUsage ¶
Total, used and free bytes of the volume holding path the way shutil.disk_usage reports them on POSIX
func ExtractTarDataReader ¶
Extracts a tar stream into destination like TarFile.extractall with filter data
func Filemode ¶
Ten character mode string of a raw st_mode like stat.filemode from the C _stat module
func HolderFileLock ¶
func HolderFileLock(lockPath string, holder *LockHolder, timeout time.Duration, timeoutMessage string) (func(), error)
Takes the cross process advisory lock at lockPath, reentrant per goroutine, failing with the message at the deadline
func IsContendedReplaceError ¶
Contended rename retries only exist on Windows
func IsCrossDeviceError ¶
Cross device and busy target renames fall back to a copy
func LockFile ¶
Blocks until f holds an exclusive whole file flock, retrying interrupted waits as fcntl.flock does
func LockHolderHint ¶
Live holder hint from the pid a holder stamps into the lock file, empty for none, a dead pid or this process
func LstatIdentity ¶
Device and inode numbers os.lstat reports for a path, a final link not followed
func MakeTargz ¶
Writes base.tar.gz of rootDir/baseDir in GNU format through a sibling temp file renamed on completion
func Makedirs ¶
os.makedirs creating missing parents first, an existing directory accepted when existOK
func MkstempBeside ¶
Temp file in the directory a later AtomicReplace publishes into, beside the link when that one is unwritable
func ModeForWrite ¶
Existing permission bits of path when preserving, else the create mode for a file that does not exist
func Move ¶
Moves a file or tree like shutil.move with copy2, the result empty for the same file rename
func NormalizeArchiveParts ¶
Safe relative parts of an archive member name, refusing absolute, drive, empty and parent references
func OSErrorText ¶
Python str of an OS error, errno number and description followed by the quoted path
func PlatformNewlines ¶
Text mode writes keep LF on POSIX hosts
func PosixModeBits ¶
Octal permission bits of a FileMode with the setuid, setgid and sticky flags folded into their positions
func PreserveFileMode ¶
All twelve permission bits of the file path names, false when it is missing or cannot be read
func ReadTextChars ¶
open(path, encoding utf-8 or utf-8-sig).read(n) with TextIOWrapper chunking, universal newlines and strict errors
func RemoveTempDir ¶
Removes a temporary directory like tempfile.TemporaryDirectory cleanup, resetting permissions of denied entries
func RestoreFileMode ¶
Applies permission bits to path when a mode was captured, ignoring a refusal
func RestoreFileOwner ¶
Gives a replaced file back to its previous owner, ignoring a refusal, a nil owner leaving it alone
func RmTree ¶
Removes a tree like shutil.rmtree, routing every failure through onexc or returning the first one when onexc is nil
func SafeExtractTargz ¶
Extracts only directories and regular files, failing on links, devices and escaping names
func TarMemberNames ¶
Member names of a gzip or plain tar archive in stream order
func TryLockFile ¶
One non blocking exclusive flock attempt, false without error when another handle holds it
func UnlinkFilesOlderThan ¶
Deletes regular files matching the pattern whose mtime is more than the age before now and returns the count
Types ¶
type ArchiveError ¶
type ArchiveError struct{ Msg string }
Error for an unsafe or unsupported archive member, the ValueError of
func (*ArchiveError) Error ¶
func (e *ArchiveError) Error() string
type CopyTreeError ¶
type CopyTreeError struct{ Failures [][3]string }
Failures gathered by a tree copy as source, destination and reason triples
func (*CopyTreeError) Error ¶
func (e *CopyTreeError) Error() string
type EncodeError ¶
type EncodeError struct{ Msg string }
UnicodeEncodeError Python raises writing text with lone surrogates as utf-8
func (*EncodeError) Error ¶
func (e *EncodeError) Error() string
type FileOwner ¶
type FileOwner struct{ UID, GID int }
Owning uid and gid of a file on a POSIX host
func PreserveFileOwner ¶
Owner of the file path names, nil when it cannot be read
type IgnoreErrFunc ¶
Names of a directory listing a tree copy skips, or an error that stops the whole copy
type IgnoreFunc ¶
Names of a directory listing a tree copy skips
type LockHolder ¶
type LockHolder struct {
// contains filtered or unexported fields
}
Per goroutine reentrancy depth of one advisory lock, the holder its users share
func (*LockHolder) Depth ¶
func (h *LockHolder) Depth() int
Depth the calling goroutine holds the lock at, zero when it does not hold it
type LockTimeoutError ¶
type LockTimeoutError struct{ Message string }
Python TimeoutError a holder lock waiter raises once its deadline passes
func (*LockTimeoutError) Error ¶
func (e *LockTimeoutError) Error() string
type MoveError ¶
type MoveError struct{ Msg string }
shutil.Error raised for a move whose destination exists or lies inside the source
type MovePermissionError ¶
type MovePermissionError struct{ Msg string }
PermissionError raised for a tree that is immutable or that macOS will not let the caller empty
func (*MovePermissionError) Error ¶
func (e *MovePermissionError) Error() string
func (*MovePermissionError) PyTypeName ¶
func (e *MovePermissionError) PyTypeName() string
Python class name of the error
func (*MovePermissionError) Unwrap ¶
func (e *MovePermissionError) Unwrap() error
Lets errors.Is match the permission class
type RmTreeOp ¶
Operation an rmtree error came from, re-runnable by the error handler like the func argument of onexc
type TarAdder ¶
TarAdder writes paths into a tar stream like tarfile.TarFile.add, tracking hard links across calls
type TarFilterError ¶
Refusal of a member by the tarfile data filter, Class naming the tarfile.FilterError subclass
func (*TarFilterError) Error ¶
func (e *TarFilterError) Error() string
type TextWrite ¶
type TextWrite struct {
Prefix string
PreserveMode bool
CreateMode *os.FileMode
Mode *os.FileMode
FsyncDir bool
}
Keyword arguments of an atomic text write, Mode forcing the bits and CreateMode applying to a new file only
type UnicodeDecodeError ¶
UnicodeDecodeError a strict utf-8 text read raises for bytes that do not decode
func (*UnicodeDecodeError) Error ¶
func (e *UnicodeDecodeError) Error() string
Source Files
¶
- archive.go
- atomic.go
- atomic_bytes.go
- atomic_unix.go
- copytree.go
- copytree_unix.go
- diskusage_frsize_linux.go
- diskusage_unix.go
- filemode.go
- flock_unix.go
- holder_lock.go
- holder_lock_unix.go
- identity_unix.go
- makedirs.go
- metadata.go
- metadata_unix.go
- move.go
- move_immutable_other.go
- move_unix.go
- rmtree.go
- stage.go
- tardata.go
- tarfile_add.go
- tempdir.go
- tempdir_perms_other.go
- textread.go
- trylock_unix.go
- unlink_older.go
- walk.go