Documentation
¶
Index ¶
- Variables
- func IsExist(err error) bool
- func IsNotExist(err error) bool
- func IsPermission(err error) bool
- type COW
- func (fs *COW) Chmod(path Path, mode os.FileMode) error
- func (fs *COW) Chtimes(path Path, atime time.Time, mtime time.Time) error
- func (fs *COW) Create(path Path) (FileWriter, error)
- func (fs *COW) Finish() error
- func (fs *COW) Keep(path Path) error
- func (fs *COW) Lchown(path Path, uid, gid int) error
- func (fs *COW) Link(oldpath Path, newpath Path) error
- func (fs *COW) Mkdir(path Path, mode os.FileMode, uid, gid int) error
- func (fs *COW) Open(path Path) (FileReader, error)
- func (fs *COW) Readlink(path Path) (Path, error)
- func (fs *COW) Remove(path Path) error
- func (fs *COW) RemoveAll(path Path) error
- func (fs *COW) Rename(oldpath Path, newpath Path) error
- func (fs *COW) Stat() (FSInfo, error)
- func (fs *COW) Symlink(oldpath Path, newpath Path) error
- type FSInfo
- type FileAttrs
- type FileReader
- type FileWriter
- type Local
- func (fs *Local) Chmod(path Path, mode os.FileMode) error
- func (fs *Local) Chtimes(path Path, atime time.Time, mtime time.Time) error
- func (fs *Local) Create(path Path) (FileWriter, error)
- func (fs *Local) Keep(path Path) error
- func (fs *Local) Lchown(path Path, uid, gid int) error
- func (fs *Local) Link(oldpath Path, newpath Path) error
- func (fs *Local) Mkdir(path Path, mode os.FileMode, uid, gid int) error
- func (fs *Local) Open(path Path) (FileReader, error)
- func (fs *Local) Readlink(path Path) (Path, error)
- func (fs *Local) Remove(path Path) error
- func (fs *Local) RemoveAll(path Path) error
- func (fs *Local) Rename(oldpath Path, newpath Path) error
- func (fs *Local) Stat() (FSInfo, error)
- func (fs *Local) Symlink(oldpath Path, newpath Path) error
- type Path
- type ReadableFileSystem
- type SFTP
- func (fs *SFTP) Chmod(path Path, mode os.FileMode) error
- func (fs *SFTP) Chtimes(path Path, atime time.Time, mtime time.Time) error
- func (fs *SFTP) Create(path Path) (FileWriter, error)
- func (fs *SFTP) Keep(path Path) error
- func (fs *SFTP) Lchown(path Path, uid, gid int) error
- func (fs *SFTP) Link(oldpath Path, newpath Path) error
- func (fs *SFTP) Mkdir(path Path, mode os.FileMode, uid, gid int) error
- func (fs *SFTP) Open(path Path) (FileReader, error)
- func (fs *SFTP) Readlink(path Path) (Path, error)
- func (fs *SFTP) Remove(path Path) error
- func (fs *SFTP) RemoveAll(path Path) error
- func (fs *SFTP) Rename(oldpath Path, newpath Path) error
- func (fs *SFTP) Stat() (FSInfo, error)
- func (fs *SFTP) Symlink(oldpath Path, newpath Path) error
- type WriteableFileSystem
Constants ¶
This section is empty.
Variables ¶
var ErrHostIsEmpty = errors.New("host must be non-empty")
Functions ¶
func IsNotExist ¶
IsNotExist is like os.IsNotExist, but also handles non-local file systems.
func IsPermission ¶
IsPermission is like os.IsPermission, but also handles non-local file systems.
Types ¶
type COW ¶
type COW struct {
// contains filtered or unexported fields
}
COW is a per-host, timestamped, copy-on-write file system. Its Keep function hardlinks a file from the latest time of the same host, if it exists. Otherwise it takes the latest time of any host.
On Finish, the file system writes a "<host>/<time>.complete" file and updates the ".latest" symlinks.
type FSInfo ¶
type FSInfo struct {
// FreeSpace describes how many bytes are available for use.
FreeSpace uint64
}
FSInfo carries statistics about a file system.
type FileReader ¶
type FileReader interface {
io.Reader
io.Closer
// Readdir returns all directory entries, if the file represents a directory.
Readdir() ([]os.FileInfo, error)
// Stat returns metadata about the file.
Stat() (os.FileInfo, error)
}
A FileReader represents an open file stream or directory that can be read from.
type FileWriter ¶
type FileWriter interface {
io.Writer
io.Closer
// Chmod changes file modes and permissions.
Chmod(os.FileMode) error
// Lchown changes the owner or group of the file.
// If uid or gid are -1, that value is ignored.
Chown(uid, gid int) error
}
A FileWriter represents an open file stream that can be written to.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a file system working on the OS native file system.
func (*Local) Chtimes ¶
Chtimes modifies the file or directory metadata for access and modification times.
func (*Local) Create ¶
func (fs *Local) Create(path Path) (FileWriter, error)
Create creates (or overwrites) a file and opens it for writing.
func (*Local) Lchown ¶
Lchown changes the owner or group of a file or directory. If uid or gid are -1, that value is ignored. Symlinks are updated, not followed.
func (*Local) Open ¶
func (fs *Local) Open(path Path) (FileReader, error)
Open opens a file or directory for reading.
type Path ¶
type Path string
A Path points to a file or directory within a file system. They are always relative the root of the file system and never starts with a directory separator.
type ReadableFileSystem ¶
type ReadableFileSystem interface {
// Open opens a file or directory for reading.
Open(path Path) (FileReader, error)
// Readlink returns the contents of the given symlink.
Readlink(path Path) (Path, error)
// Stat returns information about this file system.
Stat() (FSInfo, error)
}
A ReadableFileSystem can only be read from.
type SFTP ¶
type SFTP struct {
// contains filtered or unexported fields
}
An SFTP uses SFTP to read and write files. It doesn't do retries, and should be used together with remote.ReconnectingSFTPClient and remote.Idempotent.
type WriteableFileSystem ¶
type WriteableFileSystem interface {
ReadableFileSystem
// Create creates (or overwrites) a file and opens it for writing.
Create(path Path) (FileWriter, error)
// Keep informs the file system that the file should be kept.
Keep(path Path) error
// Mkdir creates a new directory. If uid or gid are -1, that value is ignored.
Mkdir(path Path, mode os.FileMode, uid, gid int) error
// Link creates a hardlink to an existing file.
Link(oldpath Path, newpath Path) error
// Symlink creates a symlink pointing to a file or directory.
Symlink(oldpath Path, newpath Path) error
// Rename moves a file or directory from one path to another.
Rename(oldpath Path, newpath Path) error
// RemoveAll recursively deletes a directory (or file).
RemoveAll(path Path) error
// Remove deletes a file or empty directory.
Remove(path Path) error
// Chmod changes file or directory modes and permissions.
Chmod(Path, os.FileMode) error
// Lchown changes the owner or group of a file or directory.
// If uid or gid are -1, that value is ignored. Symlinks are updated, not followed.
Lchown(path Path, uid, gid int) error
// Chtimes modifies the file or directory metadata for access and modification times.
Chtimes(path Path, atime time.Time, mtime time.Time) error
}
A WriteableFileSystem can be both used to both read and write files.