filesystem

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS interface {

	// RootDir returns the Root directory of the file system
	RootDir() string
	// Dir returns a list of files in the given directory
	Dir(folderName string) ([]string, []os.FileInfo, error)
	// CheckDir checks if the given directory exists
	CheckDir(string) error
	// MakeDir creates a new directory with the given name
	MakeDir(folderName string) error
	// ReadFile reads the file and writes it to the given writer
	ReadFile(string, io.Writer) (int64, error)
	// WriteFile creates a new file with the given name and writes the data from the reader
	// filename is the name of the file to create
	// r is the reader that contains the data to write to the file
	// transferType is the transfer type "A" for ASCII or "I" for binary
	// appendOnly is true if the file should be opened in append mode not rewrite mode
	WriteFile(fileName string, r io.Reader, transferType string, appendOnly bool) error
	// Remove removes the file
	// fileName is the name of the file to remove
	Remove(fileName string) error
	// Rename renames the file/folder or moves it to a different directory
	Rename(original string, target string) error
	// ModifyTime changes the file modification time
	ModifyTime(string, string) error
	// Stat returns the file info without following the link
	Stat(fileName string) (string, fs.FileInfo, error)
	// SetStat changes the file info
	SetStat(fileName string, newPermissions os.FileMode) error
	// Lstat returns the file info without following the link
	Lstat(fileName string) (string, fs.FileInfo, error)
	// Link creates a hard link pointing to a file.
	Link(fileName string, target string) error
	// Symlink creates a symbolic link pointing to a file or directory.
	Symlink(fileName string, target string) error
}

FS is filesystem the interface that wraps the basic methods for a FTP,FTPS,SFTP file system The FTP server uses this interface to interact with the file system CheckDir checks if the given directory exists RootDir returns the Root directory of the file system Dir returns a list of files in the given directory Read reads the file and writes it to the given writer Create creates a new file with the given name and writes the data from the reader Remove removes the file/directory Rename renames the file/directory or moves it to a different directory Stat returns the file info SetStat changes the file info Lstat returns the file info without following the link Link creates a hard link pointing to a file. Symlink creates a symbolic link pointing to a file or directory.

type FSWithReadWriteAt

type FSWithReadWriteAt interface {
	FS

	// FileWrite creates/update a new file with the given name and writes the data from the reader
	FileWrite(fileName string, access int) (io.WriterAt, error)

	// FileRead reads the file at the given offset and writes it to the given writer
	FileRead(fileName string, access int) (io.ReaderAt, error)
	// StatFS FileStatFS returns the file system status of the file system containing the file
	StatFS(path string) (*sftp.StatVFS, error)
}

FSWithReadWriteAt is the interface that wraps the basic methods for a SFTP file system

type LocalFS

type LocalFS struct {
	FS fs.FS
	// contains filtered or unexported fields
}

LocalFS is a local file system that implements the FtpFS interface

func NewLocalFS

func NewLocalFS(localDir string) *LocalFS

func (*LocalFS) CheckDir

func (FS *LocalFS) CheckDir(dirName string) (err error)

CheckDir checks if the given directory exists

func (*LocalFS) Dir

func (FS *LocalFS) Dir(dirName string) ([]string, []os.FileInfo, error)

Dir returns a list of files in the given directory

func (*LocalFS) File

func (FS *LocalFS) File(fileName string, access int) (*os.File, error)

File reads the file at the given offset and writes it to the given writer

func (*LocalFS) FileRead

func (FS *LocalFS) FileRead(fileName string, access int) (io.ReaderAt, error)

func (*LocalFS) FileWrite

func (FS *LocalFS) FileWrite(fileName string, access int) (io.WriterAt, error)

func (*LocalFS) GetFS

func (FS *LocalFS) GetFS() fs.FS
func (FS *LocalFS) Link(fileName string, target string) (err error)

Link creates a hard link pointing to a file.

func (*LocalFS) Lstat

func (FS *LocalFS) Lstat(fileName string) (string, fs.FileInfo, error)

Lstat returns the file info without following the link

func (*LocalFS) MakeDir

func (FS *LocalFS) MakeDir(folderName string) error

MakeDir creates a new directory with the given name

func (*LocalFS) ModifyTime

func (FS *LocalFS) ModifyTime(filePath string, newTime string) (err error)

ModifyTime changes the file modification time

func (*LocalFS) ReadFile

func (FS *LocalFS) ReadFile(name string, w io.Writer) (int64, error)

ReadFile reads the file and writes it to the given writer

func (*LocalFS) Remove

func (FS *LocalFS) Remove(fileName string) (err error)

Remove removes the file

func (*LocalFS) Rename

func (FS *LocalFS) Rename(fileName, newName string) (err error)

Rename renames the file or moves it to a different directory

func (*LocalFS) RootDir

func (FS *LocalFS) RootDir() string

RootDir returns the Root directory of the file system

func (*LocalFS) SetStat

func (FS *LocalFS) SetStat(fileName string, newPermission os.FileMode) error

SetStat changes the file info

func (*LocalFS) Stat

func (FS *LocalFS) Stat(fileName string) (string, fs.FileInfo, error)

Stat returns the file info

func (*LocalFS) StatFS

func (FS *LocalFS) StatFS(path string) (*sftp.StatVFS, error)

StatFS FileStatFS returns the file system status of the file system containing the file

func (FS *LocalFS) Symlink(fileName string, target string) (err error)

Symlink creates a symbolic link pointing to a file or directory.

func (*LocalFS) WriteFile

func (FS *LocalFS) WriteFile(fileName string, r io.Reader, transferType string, appendOnly bool) error

WriteFile creates a new file with the given name and writes the data from the reader

type NewFS

type NewFS interface {
	FS
	// GetFS returns the fs.FS object
	GetFS() fs.FS
}

NewFS implement the FS interface add support for the New 1.16 fs.FS interface

type NewFSWithReadWriteAt

type NewFSWithReadWriteAt interface {
	NewFS
	FSWithReadWriteAt
}

NewFSWithReadWriteAt implement the FSWithFile interface add support for the New 1.16 fs.FS interface

Jump to

Keyboard shortcuts

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