filesystem

package
v0.0.0-...-a532a67 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: LGPL-3.0 Imports: 3 Imported by: 36

Documentation

Index

Constants

View Source
const (
	// FilespaceID ia a default dependency name
	FilespaceID = "Filespace"
	// DefaultUnixFileMode is a default file mode for unix base filesystems
	DefaultUnixFileMode = 0644
	// DefaultUnixDirMode is a default dir mode for unix base filesystems
	DefaultUnixDirMode = 0777
	// SafeFilePermissions is a safe file mode for unix base filesystems (allow owner access only)
	SafeFilePermissions = 0600
	// SafeDirPermissions is a safe directory mode for unix base filesystems (allow owner access only)
	SafeDirPermissions = 0700
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	Filespace() Filespace
	Path() string

	IsExist() bool
	IsFile() bool
	ReadFile() ([]byte, error)
	WriteFile(data []byte, perm os.FileMode) error
	Reader() (Reader, error)
	Writer() (Writer, error)
	Remove() error

	MIME() string
	Name() string
	CreateTime() time.Time
}

File is a files wraper

type Filespace

type Filespace interface {
	Copy(src, dest string) error
	CopyDirectory(src, dest string) error
	CopyFile(src, dest string) error
	ReadDir(path string) ([]os.FileInfo, error)
	IsExist(subPath string) bool
	IsFile(subPath string) bool
	IsDir(subPath string) bool
	MkdirAll(subPath string, filemode os.FileMode) error
	ReadFile(subPath string) ([]byte, error)
	WriteFile(subPath string, data []byte, perm os.FileMode) error
	Filespace(subPath string) (Filespace, error)
	Reader(subPath string) (Reader, error)
	Writer(subPath string) (Writer, error)
	Remove(subPath string) error
	RemoveAll(subPath string) error
	Lstat(subPath string) (os.FileInfo, error)
}

Filespace is a abstract filesystem interface

type LocalFilespace

type LocalFilespace interface {
	Filespace
	// LocalPath return path in local filesystem
	LocalPath() string
}

LocalFilespace is a filesystem interface on local harddisk

type Loop

type Loop interface {
	OnFile(LoopOn)
	OnDir(LoopOn)
	Filter(LoopFilter)
	Run(fs Filespace) error
}

Loop is standard loop interface

type LoopFilter

type LoopFilter func(fs Filespace, subPath string) bool

LoopFilter is a callback type which is used to filter filespace tree

type LoopOn

type LoopOn func(fs Filespace, subPath string) error

LoopOn is a callback type trigged on a file or directory

type Reader

type Reader interface {
	io.ReadCloser
}

Reader is a reader stream

type Writer

type Writer interface {
	io.WriteCloser
}

Writer is a Writer stream

Jump to

Keyboard shortcuts

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