rigfs

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Overview

Package rigfs provides fs.FS implementations for remote filesystems.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotRunning is returned when the rigrcp process is not running
	ErrNotRunning = errors.New("rigrcp is not running")
	// ErrRcpCommandFailed is returned when a command to the rigrcp process fails
	ErrRcpCommandFailed = errors.New("rigrcp command failed")
)
View Source
var ErrCommandFailed = errors.New("command failed")

ErrCommandFailed is returned when a remote command fails

Functions

This section is empty.

Types

type File

type File interface {
	fs.File
	io.WriteCloser
	io.Seeker
	Copy(io.Writer) (int64, error)
	CopyFromN(io.Reader, int64, io.Writer) (int64, error)
}

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 FileMode

type FileMode int

FileMode is used to set the type of allowed operations when opening remote files

const (
	ModeRead      FileMode = 1                    // ModeRead = Read only
	ModeWrite     FileMode = 2                    // ModeWrite = Write only
	ModeReadWrite FileMode = ModeRead | ModeWrite // ModeReadWrite = Read and Write
	ModeCreate    FileMode = 4 | ModeWrite        // ModeCreate = Create a new file or truncate an existing one. Includes write permission.
	ModeAppend    FileMode = 8 | ModeCreate       // ModeAppend = Append to an existing file. Includes create and write permissions.
)

type Fsys

type Fsys interface {
	fs.FS
	OpenFile(string, FileMode, FileMode) (File, error)
	Sha256(string) (string, error)
	Stat(string) (fs.FileInfo, error)
	Remove(string) error
	RemoveAll(string) error
	MkDirAll(string, 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) 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) Copy

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

Copy copies the remote file at src to the local file at dst

func (*PosixFile) CopyFromN

func (f *PosixFile) CopyFromN(src io.Reader, num int64, alt io.Writer) (int64, error)

CopyFromN copies n bytes from the remote file at src to the local file at dst

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: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 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)

Write writes len(p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early.

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) MkDirAll added in v0.12.0

func (fsys *PosixFsys) MkDirAll(name string, perm 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, mode FileMode, perm FileMode) (File, error)

OpenFile is the generalized open call; most users will use Open instead.

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.

type Waiter

type Waiter interface {
	Wait() error
}

Waiter is an interface that has a Wait() function that blocks until a command is finished

type WinFsys

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

WinFsys is a fs.FS implementation for remote Windows hosts

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, _ FileMode) error

MkDirAll creates a directory named path, along with any necessary parents. The permission bits perm 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, mode FileMode, _ FileMode) (File, error)

OpenFile opens the named remote file with the specified FileMode. Permission bits are ignored on Windows.

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