driver

package
v0.0.0-...-14e102d Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOption         = errors.New("driver's option err")
	ErrNotSupport     = errors.New("operate not support")
	ErrSrcNotExist    = errors.New("src is not exists")
	ErrDstNotExist    = errors.New("dst is not exists")
	ErrDstIsExist     = errors.New("dst already exists")
	ErrDriverNotExist = errors.New("driver is not exists")
	ErrOpenDirectory  = errors.New("can't open a directory")

	VerifyOption = util.VerifyOption
)

Functions

func Copy

func Copy(ctx context.Context, srcFS FS, src, dst string, metas ...Meta) error

func CopyDir

func CopyDir(ctx context.Context, srcFS FS, src, dst string) error

func CopyFile

func CopyFile(ctx context.Context, srcFS FS, src, dst string) error

func Exists

func Exists(driver string) bool

func NewMeta

func NewMeta(metas ...Meta) *meta

func Register

func Register(typ string, creator OptionCreator)

func Verify

func Verify(driver string, option string) error

func WalkDir

func WalkDir(ctx context.Context, srcFS FS, root string, walkDirFn WalkDirFunc) error

Types

type Base

type Base struct{}

func (Base) Close

func (Base) Close() error

func (Base) Copy

func (Base) Create

func (Base) Create(string) (FileWriter, error)

func (Base) Get

func (Base) Get(context.Context, string) (File, error)

func (Base) List

func (Base) List(context.Context, string, ...Meta) ([]File, error)

func (Base) MakeDir

func (Base) MakeDir(context.Context, string) error

func (Base) Move

func (Base) Open

func (Base) Open(string) (FileReader, error)

func (Base) Remove

func (Base) Remove(context.Context, string) error

func (Base) Rename

func (Base) Rename(context.Context, string, string) error

type FS

func DriverFS

func DriverFS(driver string, option string) (FS, error)

func NewFS

func NewFS(fn func(string) (FS, string, error), fileFn func(string, File) File) FS

type File

type File interface {
	fs.FileInfo
	Type() string
	Path() string
	ExtraInfo() map[string]any
}

func NewFile

func NewFile(path string, info fs.FileInfo, opts ...func(*FileInfo)) File

type FileInfo

type FileInfo struct {
	Name      string         `json:"name"`
	Type      string         `json:"type"`
	Size      int64          `json:"size"`
	Path      string         `json:"path"`
	Mode      fs.FileMode    `json:"mode"`
	IsDir     bool           `json:"is_dir"`
	ModTime   time.Time      `json:"mod_time"`
	ExtraInfo map[string]any `json:"extra_info"`
}

func (*FileInfo) File

func (info *FileInfo) File() File

type FileReader

type FileReader interface {
	io.Seeker
	io.ReadCloser
}

func NewFileReader

func NewFileReader(size int64, rangeFunc func(int64, int64) (io.ReadCloser, error)) (FileReader, error)

type FileWriter

type FileWriter interface {
	io.WriteCloser
}

type Meta

type Meta func(*meta)

func WithAutoRename

func WithAutoRename(rename bool) Meta

func WithForce

func WithForce(force bool) Meta

func WithMeta

func WithMeta(m map[string]any) Meta

func WithOrder

func WithOrder(order string, desc bool) Meta

func WithOverride

func WithOverride(pw string) Meta

func WithPagination

func WithPagination(page int, pageSize int) Meta

func WithPassword

func WithPassword(pw string) Meta

type Option

type Option interface {
	NewFS() (FS, error)
}

type OptionCreator

type OptionCreator func() Option

type WalkDirFunc

type WalkDirFunc func(string, File, error) error

Directories

Path Synopsis
aes

Jump to

Keyboard shortcuts

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