rigfs

package
v0.18.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Overview

Package rigfs provides fs.FS implementations for remote filesystems.

Index

Constants

View Source
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

View Source
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

func (*ByteCounter) Write added in v0.17.0

func (bc *ByteCounter) Write(p []byte) (int, error)

Write implements io.Writer

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 File

type File interface {
	fs.File
	io.Seeker
	io.ReadCloser
	io.Writer
	Copier
}

File is a file in the remote filesystem

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) FullPath

func (f *FileInfo) FullPath() string

FullPath returns the full path

func (*FileInfo) Info

func (f *FileInfo) Info() (fs.FileInfo, error)

Info returns self. It's here to satisfy fs.DirEntry interface.

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

IsDir returns true if the file path points to a directory

func (*FileInfo) ModTime

func (f *FileInfo) ModTime() time.Time

ModTime returns the last modification time of a file

func (*FileInfo) Mode

func (f *FileInfo) Mode() fs.FileMode

Mode returns the file permission mode

func (*FileInfo) Name

func (f *FileInfo) Name() string

Name returns the file name

func (*FileInfo) Size

func (f *FileInfo) Size() int64

Size returns the file size

func (*FileInfo) Sys

func (f *FileInfo) Sys() any

Sys returns the underlying data source

func (*FileInfo) Type

func (f *FileInfo) Type() fs.FileMode

Type returns the file type. It's here to satisfy fs.DirEntry interface.

func (*FileInfo) UnmarshalJSON

func (f *FileInfo) UnmarshalJSON(b []byte) error

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

func NewFsys

func NewFsys(c connection, opts ...exec.Option) Fsys

NewFsys returns a fs.FS implementation for a remote filesystem

type PosixDir

type PosixDir struct {
	PosixFile
	// contains filtered or unexported fields
}

PosixDir implements fs.ReadDirFile for a remote directory

func (*PosixDir) Name added in v0.16.0

func (w *PosixDir) Name() string

func (*PosixDir) ReadDir

func (f *PosixDir) ReadDir(n int) ([]fs.DirEntry, error)

ReadDir returns a list of directory entries

type PosixFile

type PosixFile struct {
	// contains filtered or unexported fields
}

PosixFile implements fs.File for a remote file

func (*PosixFile) Close

func (f *PosixFile) Close() error

Close closes the file, rendering it unusable for I/O. It returns an error, if any.

func (*PosixFile) CopyFrom added in v0.17.0

func (f *PosixFile) CopyFrom(src io.Reader) (int64, error)

CopyFrom copies the local reader src to the remote file

func (*PosixFile) CopyTo added in v0.17.0

func (f *PosixFile) CopyTo(dst io.Writer) (int64, error)

CopyTo copies the remote file to the writer dst

func (*PosixFile) Name added in v0.16.0

func (w *PosixFile) Name() string

func (*PosixFile) Read

func (f *PosixFile) Read(p []byte) (int, error)

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

func (f *PosixFile) Seek(offset int64, whence int) (int64, error)

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.

func (*PosixFile) Stat

func (f *PosixFile) Stat() (fs.FileInfo, error)

Stat returns a FileInfo describing the named file

func (*PosixFile) Write

func (f *PosixFile) Write(p []byte) (int, error)

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

func NewPosixFsys(conn connection, opts ...exec.Option) *PosixFsys

NewPosixFsys returns a fs.FS implementation for a remote filesystem that uses POSIX commands for access

func (*PosixFsys) Chmod added in v0.16.0

func (fsys *PosixFsys) Chmod(name string, mode fs.FileMode) error

Chmod changes the mode of the named file to mode

func (*PosixFsys) MkDirAll added in v0.12.0

func (fsys *PosixFsys) MkDirAll(name string, perm fs.FileMode) error

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) Open

func (fsys *PosixFsys) Open(name string) (fs.File, error)

Open opens the named file for reading.

func (*PosixFsys) OpenFile

func (fsys *PosixFsys) OpenFile(name string, flags int, perm fs.FileMode) (File, error)

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

func (fsys *PosixFsys) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the directory named by dirname and returns a list of directory entries

func (*PosixFsys) Remove added in v0.12.0

func (fsys *PosixFsys) Remove(name string) error

Remove deletes the named file or (empty) directory.

func (*PosixFsys) RemoveAll added in v0.12.0

func (fsys *PosixFsys) RemoveAll(name string) error

RemoveAll removes path and any children it contains.

func (*PosixFsys) Sha256

func (fsys *PosixFsys) Sha256(name string) (string, error)

Sha256 returns the sha256 checksum of the file at path

func (*PosixFsys) Stat

func (fsys *PosixFsys) Stat(name string) (fs.FileInfo, error)

Stat returns the FileInfo structure describing file.

func (*PosixFsys) Touch added in v0.16.0

func (fsys *PosixFsys) Touch(name string) error

Touch creates a new empty file at path or updates the timestamp of an existing file to the current time

func (*PosixFsys) TouchT added in v0.16.0

func (fsys *PosixFsys) TouchT(name string, t time.Time) error

TouchT creates a new empty file at path or updates the timestamp of an existing file to the specified time

func (*PosixFsys) Truncate added in v0.16.0

func (fsys *PosixFsys) Truncate(name string, size int64) error

Truncate changes the size of the named file or creates a new file if it doesn't exist

type WinFsys

type WinFsys struct {
	// contains filtered or unexported fields
}

WinFsys is a fs.FS implemen{

func NewWindowsFsys

func NewWindowsFsys(conn connection, opts ...exec.Option) *WinFsys

NewWindowsFsys returns a new fs.FS implementing filesystem for Windows targets

func (*WinFsys) MkDirAll added in v0.12.0

func (fsys *WinFsys) MkDirAll(name string, _ fs.FileMode) error

MkDirAll creates a directory named path, along with any necessary parents. The permission bits are ignored on Windows.

func (*WinFsys) Open

func (fsys *WinFsys) Open(name string) (fs.File, error)

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

func (fsys *WinFsys) OpenFile(name string, flags int, _ fs.FileMode) (File, error)

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

func (fsys *WinFsys) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the directory named by dirname and returns a list of directory entries.

func (*WinFsys) Remove added in v0.12.0

func (fsys *WinFsys) Remove(name string) error

Remove deletes the named file or (empty) directory.

func (*WinFsys) RemoveAll added in v0.12.0

func (fsys *WinFsys) RemoveAll(name string) error

RemoveAll deletes the named file or directory and all its child items

func (*WinFsys) Sha256

func (fsys *WinFsys) Sha256(name string) (string, error)

Sha256 returns the SHA256 hash of the remote file.

func (*WinFsys) Stat

func (fsys *WinFsys) Stat(name string) (fs.FileInfo, error)

Stat returns fs.FileInfo for the remote file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL