Documentation
¶
Overview ¶
Package vfs gives the local disk and a remote host the same file system interface, so the file manager and transfer engine treat them alike.
Index ¶
- func Sort(entries []Entry, by SortBy)
- type Entry
- type FS
- type LocalFS
- func (LocalFS) Base(path string) string
- func (LocalFS) Chmod(path string, mode fs.FileMode) error
- func (LocalFS) Chtimes(path string, mtime time.Time) error
- func (LocalFS) Create(path string) (io.WriteCloser, error)
- func (LocalFS) Dir(path string) string
- func (LocalFS) Home() (string, error)
- func (LocalFS) Join(elem ...string) string
- func (LocalFS) Mkdir(path string) error
- func (LocalFS) MkdirAll(path string) error
- func (LocalFS) Name() string
- func (LocalFS) Open(path string) (io.ReadCloser, error)
- func (l LocalFS) ReadDir(path string) ([]Entry, error)
- func (LocalFS) Remote() bool
- func (LocalFS) Remove(path string) error
- func (LocalFS) Rename(from, to string) error
- func (l LocalFS) Stat(path string) (Entry, error)
- type RemoteFS
- func (r *RemoteFS) Base(p string) string
- func (r *RemoteFS) Chmod(p string, mode fs.FileMode) error
- func (r *RemoteFS) Chtimes(p string, mtime time.Time) error
- func (r *RemoteFS) Close() error
- func (r *RemoteFS) Create(p string) (io.WriteCloser, error)
- func (r *RemoteFS) Dir(p string) string
- func (r *RemoteFS) Home() (string, error)
- func (r *RemoteFS) Join(elem ...string) string
- func (r *RemoteFS) Mkdir(p string) error
- func (r *RemoteFS) MkdirAll(p string) error
- func (r *RemoteFS) Name() string
- func (r *RemoteFS) Open(p string) (io.ReadCloser, error)
- func (r *RemoteFS) ReadDir(p string) ([]Entry, error)
- func (r *RemoteFS) RealPath(p string) (string, error)
- func (r *RemoteFS) Remote() bool
- func (r *RemoteFS) Remove(p string) error
- func (r *RemoteFS) Rename(from, to string) error
- func (r *RemoteFS) Resolve(p string) (string, error)
- func (r *RemoteFS) Stat(p string) (Entry, error)
- type SortBy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
Name string
Size int64
Mode fs.FileMode
ModTime time.Time
IsDir bool
Link string // symlink target, "" if not a link
Broken bool // symlink whose target can't be resolved
}
Entry is a directory entry. For symlinks, IsDir/Size describe the target and Link holds the link destination.
type FS ¶
type FS interface {
// Name labels the file system in the UI ("Local" or a host name).
Name() string
// Remote reports whether this is a remote file system.
Remote() bool
ReadDir(path string) ([]Entry, error)
Stat(path string) (Entry, error)
Open(path string) (io.ReadCloser, error)
// Create creates or truncates a file for writing.
Create(path string) (io.WriteCloser, error)
Mkdir(path string) error
MkdirAll(path string) error
// Remove deletes a file, or a directory recursively.
Remove(path string) error
// Rename moves from to to, replacing to if it exists.
Rename(from, to string) error
Chtimes(path string, mtime time.Time) error
Chmod(path string, mode fs.FileMode) error
Home() (string, error)
Join(elem ...string) string
Dir(path string) string
Base(path string) string
}
FS is implemented by LocalFS and RemoteFS. Paths are absolute and use the file system's own separator.
type RemoteFS ¶
type RemoteFS struct {
// contains filtered or unexported fields
}
RemoteFS is a remote host's file system over SFTP. Paths are POSIX.
func NewRemoteFS ¶
NewRemoteFS wraps an SFTP client. closer (optional) is called by Close after the client is closed, e.g. to reap the ssh process.
func (*RemoteFS) Create ¶
func (r *RemoteFS) Create(p string) (io.WriteCloser, error)
Create returns the *sftp.File itself so io.Copy can use its concurrent ReadFrom.
func (*RemoteFS) Open ¶
func (r *RemoteFS) Open(p string) (io.ReadCloser, error)
Open returns the *sftp.File itself so io.Copy can use its concurrent WriteTo.
func (*RemoteFS) Rename ¶
Rename replaces the destination atomically when the server supports the posix-rename extension (OpenSSH does), and falls back to remove+rename.