Documentation ¶
Index ¶
- Constants
- Variables
- func ClearXattr(nm string) error
- func CopyFd(dst, src *os.File) error
- func CopyFile(dst, src string, perm fs.FileMode) error
- func DelXattr(nm string, keys ...string) error
- func LclearXattr(nm string) error
- func LdelXattr(nm string, keys ...string) error
- func LreplaceXattr(nm string, x Xattr) error
- func LsetXattr(nm string, x Xattr) error
- func Lstatm(nm string, fi *Info) error
- func ReplaceXattr(nm string, x Xattr) error
- func SetXattr(nm string, x Xattr) error
- func Statm(nm string, fi *Info) error
- type CopyError
- type FioMap
- type FioPairMap
- type Info
- func (ii *Info) IsDir() bool
- func (ii *Info) IsRegular() bool
- func (a *Info) IsSameFS(b *Info) bool
- func (ii *Info) Marshal() ([]byte, error)
- func (ii *Info) MarshalSize() int
- func (ii *Info) MarshalTo(b []byte) (int, error)
- func (ii *Info) ModTime() time.Time
- func (ii *Info) Mode() fs.FileMode
- func (ii *Info) Name() string
- func (ii *Info) Size() int64
- func (ii *Info) String() string
- func (ii *Info) Sys() any
- func (ii *Info) Unmarshal(b []byte) (int, error)
- type Pair
- type SafeFile
- type WorkPool
- type Xattr
Constants ¶
const (
OPT_OVERWRITE uint32 = 1 << iota
)
Variables ¶
var ErrCompleted = errors.New("workpool: workpool closed")
Error returned if new work is submitted after Wait() or if Wait() is called multiple times.
var ErrNotClosed = errors.New("workpool: workpool not closed before waiting")
Error returned if Wait() is called without closing the work submission
var (
ErrTooSmall = errors.New("buffer is not big enough")
)
Functions ¶
func ClearXattr ¶ added in v0.2.0
ClearXattr deletes all the extended attributes of a file.
func CopyFd ¶
CopyFd copies open files 'src' to 'dst' using the most efficient OS primitive available on the runtime platform. CopyFile will use copy-on-write facailities if the underlying file-system implements it. It will fallback to copying via memory mapping 'src' and writing the blocks to 'dst'.
func CopyFile ¶
CopyFile copies files 'src' to 'dst' using the most efficient OS primitive available on the runtime platform. CopyFile will use copy-on-write facilities if the underlying file-system implements it. It will fallback to copying via memory mapping 'src' and writing the blocks to 'dst'.
func LclearXattr ¶ added in v0.2.0
ClearXattr deletes all the extended attributes of a file. If 'nm' points to a symlink, LSetXattr will delete the extended attributes of the symlink and *not* the target.
func LdelXattr ¶ added in v0.2.0
LDelXattr deletes one or more extended attributes of a file. If 'nm' points to a symlink, LSetXattr will delete the extended attributes of the symlink and *not* the target.
func LreplaceXattr ¶ added in v0.2.0
LReplaceXattr replaces all the extended attributes of 'nm' with new attributes in 'x'. This function is a combination of LclearXattr() and LsetXattr(). If 'nm' points to a symlink, LReplaceXattr will set/update the extended attributes of the symlink and *not* the target.
func LsetXattr ¶ added in v0.2.0
LSetXattr sets/updates the xattr list for a given file. If 'nm' points to a symlink, LSetXattr will set/update the extended attributes of the symlink and *not* the target.
func ReplaceXattr ¶ added in v0.2.0
ReplaceXattr replaces all the extended attributes of 'nm' with new attributes in 'x'. This function is a combination of ClearXattr() and SetXattr().
Types ¶
type CopyError ¶ added in v0.4.0
CopyError represents the errors returned by CopyFile and CopyFd
type FioMap ¶ added in v0.5.3
FioMap is a concurrency safe map of relative path name and the corresponding Stat/Lstat info.
type FioPairMap ¶ added in v0.5.3
FioPairMap is a concurrency safe map of relative path name and the corresponding Stat/Lstat info of both the source and destination.
func NewFioPairMap ¶ added in v0.5.3
func NewFioPairMap() *FioPairMap
type Info ¶ added in v0.2.0
type Info struct { Ino uint64 Siz int64 Dev uint64 Rdev uint64 Mod fs.FileMode Uid uint32 Gid uint32 Nlink uint32 Atim time.Time Mtim time.Time Ctim time.Time Nam string Xattr Xattr }
Info represents a file/dir metadata in a normalized form It satisfies the fs.FileInfo interface and notably supports extended file system attributes (`xattr(7)`). This type can also be safely marshaled and unmarshaled into a portable byte stream.
func (*Info) IsRegular ¶ added in v0.2.0
IsRegular returns true if this Info represents a regular file
func (*Info) IsSameFS ¶ added in v0.3.2
IsSameFs returns true if a and b represent file entries on the same file system
func (*Info) Marshal ¶ added in v0.5.4
Marshal marshals 'ii' into a correctly sized buffer and returns it
func (*Info) MarshalSize ¶ added in v0.2.0
MarshalSize returns the marshaled size of _this_ instance of Info
func (*Info) MarshalTo ¶ added in v0.2.0
MarshalTo marshals 'ii' into the provided buffer 'b'. The buffer 'b' is expected to be sufficiently big to hold the marshaled data. It returns the number of marshaled bytes (ie exactly the value returned by the corresponding MarshalSize()).
func (*Info) Name ¶ added in v0.2.0
Name satisfies fs.FileInfo and returns the name of the fs entry.
type Pair ¶ added in v0.5.3
type Pair struct {
Src, Dst *Info
}
Pair represents the Stat/Lstat info of a pair of related file system entries in the source and destination
type SafeFile ¶
SafeFile is an io.WriteCloser which uses a temporary file that will be atomically renamed when there are no errors and caller invokes Close(). The recommended usage is:
sf, err := NewSafeFile(...) ... error handling defer sf.Abort() ... write to sf .. sf.Close()
It is safe to call Abort on a closed SafeFile; the first call to Close() or Abort() seals the outcome. Similarly, it is safe to call Close() after Abort() - the first call to either takes precedence.
func NewSafeFile ¶
NewSafeFile creates a new temporary file that would either be aborted or safely renamed to the correct name. 'nm' is the name of the final file; if 'ovwrite' is true, then the file is overwritten if it exists.
func (*SafeFile) Abort ¶
func (sf *SafeFile) Abort()
Abort the file write and remove any temporary artifacts; it is safe to call Close() on a different code path; the first call to Abort() or Close() takes precedence.
func (*SafeFile) Close ¶
Close flushes all file data & metadata to disk, closes the file and atomically renames the temp file to the actual file - ONLY if there were no intervening errors.
type WorkPool ¶ added in v0.4.0
type WorkPool[Work any] struct { // contains filtered or unexported fields }
func NewWorkPool ¶ added in v0.4.0
NewWorkPool creates a worker pool that invokes caller provided worker 'fp'. Each worker will process one unit of "work" submitted via Submit().
func (*WorkPool[Work]) Close ¶ added in v0.4.0
func (wp *WorkPool[Work]) Close()
Close the work submission to workers and signal to them that there's no more work forthcoming.
func (*WorkPool[Work]) Err ¶ added in v0.4.0
Submit an error to the pool - if the user provided worker does things asynchronously.
type Xattr ¶
Xattr is a collection of all the extended attributes of a given file
func GetXattr ¶ added in v0.2.0
GetXattr returns all the extended attributes of a file. This function will traverse symlinks.
func LgetXattr ¶ added in v0.2.0
LGetXattr returns all the extended attributes of a file. If 'nm' points to a symlink, LGetXattr will return the extended attributes of the symlink and *not* the target.