Documentation ¶
Overview ¶
Package rigfs provides fs.FS implementations for remote filesystems.
Index ¶
- Constants
- Variables
- type ByteCounter
- type Copier
- type File
- type FileInfo
- func (f *FileInfo) FullPath() string
- func (f *FileInfo) Info() (fs.FileInfo, error)
- func (f *FileInfo) IsDir() bool
- func (f *FileInfo) ModTime() time.Time
- func (f *FileInfo) Mode() fs.FileMode
- func (f *FileInfo) Name() string
- func (f *FileInfo) Size() int64
- func (f *FileInfo) Sys() any
- func (f *FileInfo) Type() fs.FileMode
- func (f *FileInfo) UnmarshalJSON(b []byte) error
- type Fsys
- type PosixDir
- type PosixFile
- func (f *PosixFile) Close() error
- func (f *PosixFile) CopyFrom(src io.Reader) (int64, error)
- func (f *PosixFile) CopyTo(dst io.Writer) (int64, error)
- func (w *PosixFile) Name() string
- func (f *PosixFile) Read(p []byte) (int, error)
- func (f *PosixFile) Seek(offset int64, whence int) (int64, error)
- func (f *PosixFile) Stat() (fs.FileInfo, error)
- func (f *PosixFile) Write(p []byte) (int, error)
- type PosixFsys
- func (fsys *PosixFsys) Chmod(name string, mode fs.FileMode) error
- func (fsys *PosixFsys) MkDirAll(name string, perm fs.FileMode) error
- func (fsys *PosixFsys) Open(name string) (fs.File, error)
- func (fsys *PosixFsys) OpenFile(name string, flags int, perm fs.FileMode) (File, error)
- func (fsys *PosixFsys) ReadDir(name string) ([]fs.DirEntry, error)
- func (fsys *PosixFsys) Remove(name string) error
- func (fsys *PosixFsys) RemoveAll(name string) error
- func (fsys *PosixFsys) Sha256(name string) (string, error)
- func (fsys *PosixFsys) Stat(name string) (fs.FileInfo, error)
- func (fsys *PosixFsys) Touch(name string) error
- func (fsys *PosixFsys) TouchT(name string, t time.Time) error
- func (fsys *PosixFsys) Truncate(name string, size int64) error
- type WinFsys
- func (fsys *WinFsys) MkDirAll(name string, _ fs.FileMode) error
- func (fsys *WinFsys) Open(name string) (fs.File, error)
- func (fsys *WinFsys) OpenFile(name string, flags int, _ fs.FileMode) (File, error)
- func (fsys *WinFsys) ReadDir(name string) ([]fs.DirEntry, error)
- func (fsys *WinFsys) Remove(name string) error
- func (fsys *WinFsys) RemoveAll(name string) error
- func (fsys *WinFsys) Sha256(name string) (string, error)
- func (fsys *WinFsys) Stat(name string) (fs.FileInfo, error)
Constants ¶
const ( OpClose = "close" // OpClose Close operation OpOpen = "open" // OpOpen Open operation OpRead = "read" // OpRead Read operation OpSeek = "seek" // OpSeek Seek operation OpStat = "stat" // OpStat Stat operation OpWrite = "write" // OpWrite Write operation OpCopyTo = "copy-to" // OpCopyTo CopyTo operation OpCopyFrom = "copy-from" // OpCopyFrom CopyFrom operation )
Variables ¶
var ErrCommandFailed = errors.New("command failed")
ErrCommandFailed is returned when a remote command fails
Functions ¶
This section is empty.
Types ¶
type ByteCounter ¶ added in v0.17.0
type ByteCounter struct {
// contains filtered or unexported fields
}
ByteCounter is a simple io.Writer that counts the number of bytes written to it, to be used in conjunction with io.MultiWriter / io.TeeReader
func (*ByteCounter) Count ¶ added in v0.17.0
func (bc *ByteCounter) Count() int64
Count returns the number of bytes written to the ByteCounter
type Copier ¶ added in v0.17.0
type Copier interface { CopyFrom(src io.Reader) (int64, error) CopyTo(dst io.Writer) (int64, error) }
Copier is a file-like struct that can copy data to and from io.Reader and io.Writer
type FileInfo ¶
type FileInfo struct { FName string `json:"name"` FSize int64 `json:"size"` FMode fs.FileMode `json:"mode"` FUnix fs.FileMode `json:"unixMode"` FModTime time.Time `json:"-"` FIsDir bool `json:"isDir"` ModtimeS int64 `json:"modTime"` // contains filtered or unexported fields }
FileInfo implements fs.FileInfo for stat on remote files
func (*FileInfo) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Fsys ¶
type Fsys interface { fs.FS OpenFile(path string, flag int, perm fs.FileMode) (File, error) Sha256(path string) (string, error) Stat(path string) (fs.FileInfo, error) Remove(path string) error RemoveAll(path string) error MkDirAll(path string, perm fs.FileMode) error }
Fsys is a filesystem on the remote host
type PosixDir ¶
type PosixDir struct { PosixFile // contains filtered or unexported fields }
PosixDir implements fs.ReadDirFile for a remote directory
type PosixFile ¶
type PosixFile struct {
// contains filtered or unexported fields
}
PosixFile implements fs.File for a remote file
func (*PosixFile) Close ¶
Close closes the file, rendering it unusable for I/O. It returns an error, if any.
func (*PosixFile) CopyFrom ¶ added in v0.17.0
CopyFrom copies the local reader src to the remote file
func (*PosixFile) Read ¶
Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered.
func (*PosixFile) Seek ¶
Seek sets the offset for the next Read or Write to offset, interpreted according to whence: io.SeekStart means relative to the origin of the file, io.SeekCurrent means relative to the current offset, and io.SeekEnd means relative to the end. Seek returns the new offset relative to the start of the file and an error, if any.
type PosixFsys ¶
type PosixFsys struct {
// contains filtered or unexported fields
}
PosixFsys implements fs.FS for a remote filesystem that uses POSIX commands for access
func NewPosixFsys ¶
NewPosixFsys returns a fs.FS implementation for a remote filesystem that uses POSIX commands for access
func (*PosixFsys) MkDirAll ¶ added in v0.12.0
MkDirAll creates a new directory structure with the specified name and permission bits. If the directory already exists, MkDirAll does nothing and returns nil.
func (*PosixFsys) OpenFile ¶
OpenFile is used to open a file with access/creation flags for reading or writing. For info on flags, see https://pkg.go.dev/os#pkg-constants
func (*PosixFsys) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries
func (*PosixFsys) Touch ¶ added in v0.16.0
Touch creates a new empty file at path or updates the timestamp of an existing file to the current time
type WinFsys ¶
type WinFsys struct {
// contains filtered or unexported fields
}
WinFsys is a fs.FS implemen{
func NewWindowsFsys ¶
NewWindowsFsys returns a new fs.FS implementing filesystem for Windows targets
func (*WinFsys) MkDirAll ¶ added in v0.12.0
MkDirAll creates a directory named path, along with any necessary parents. The permission bits are ignored on Windows.
func (*WinFsys) Open ¶
Open opens the named file for reading and returns fs.File. Use OpenFile to get a file that can be written to or if you need any of the methods not available on fs.File interface without type assertion.
func (*WinFsys) OpenFile ¶
OpenFile opens the named remote file with the specified flags. os.O_EXCL and permission bits are ignored on Windows. For a description of the flags, see https://pkg.go.dev/os#pkg-constants
func (*WinFsys) ReadDir ¶
ReadDir reads the directory named by dirname and returns a list of directory entries.
func (*WinFsys) RemoveAll ¶ added in v0.12.0
RemoveAll deletes the named file or directory and all its child items