model

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: MIT Imports: 14 Imported by: 16

Documentation

Index

Constants

View Source
const (
	DirectoryPerm   = 0o700
	RegularFilePerm = 0o600
)

Variables

View Source
var (
	ErrRelativePath = errors.New("name contains relatives paths")
	ErrInvalidPath  = errors.New("name is invalid")
)

Functions

func Dirname

func Dirname(name string) string

func ErrNotExist

func ErrNotExist(err error) error

func ID added in v0.4.3

func ID(value string) string

func IsNotExist

func IsNotExist(err error) bool

func ValidPath added in v1.4.4

func ValidPath(name string) error

Types

type FileItem added in v1.6.0

type FileItem struct {
	Storage Storage

	Item
	// contains filtered or unexported fields
}

func (*FileItem) Close added in v1.6.0

func (fi *FileItem) Close() error

func (*FileItem) Read added in v1.6.0

func (fi *FileItem) Read(p []byte) (int, error)

func (*FileItem) ReadAt added in v1.6.0

func (fi *FileItem) ReadAt(p []byte, off int64) (int, error)

func (*FileItem) Readdir added in v1.6.0

func (fi *FileItem) Readdir(count int) ([]fs.FileInfo, error)

func (*FileItem) Seek added in v1.6.0

func (fi *FileItem) Seek(offset int64, whence int) (int64, error)

type Item

type Item struct {
	Date       time.Time   `msg:"date" json:"date"`
	ID         string      `msg:"id" json:"id"`
	NameValue  string      `msg:"name" json:"name"`
	Pathname   string      `msg:"pathname" json:"pathname"`
	Extension  string      `msg:"extension" json:"extension"`
	SizeValue  int64       `msg:"size" json:"size"`
	FileMode   os.FileMode `msg:"fileMode" json:"fileMode"`
	IsDirValue bool        `msg:"isDir" json:"isDir"`
}

func (Item) Dir

func (i Item) Dir() string

func (Item) IsDir

func (i Item) IsDir() bool

func (Item) IsZero added in v1.0.4

func (i Item) IsZero() bool

func (Item) ModTime added in v1.6.0

func (i Item) ModTime() time.Time

func (Item) Mode added in v1.6.0

func (i Item) Mode() os.FileMode

func (Item) Name

func (i Item) Name() string

func (Item) Size

func (i Item) Size() int64

func (Item) String added in v1.0.10

func (i Item) String() string

func (Item) Sys added in v1.6.0

func (i Item) Sys() any

type ReadAtSeekCloser added in v1.4.4

type ReadAtSeekCloser interface {
	io.ReadSeekCloser
	io.ReaderAt
}

type Storage

type Storage interface {
	Stat(ctx context.Context, name string) (Item, error)
	Mkdir(ctx context.Context, name string, perm os.FileMode) error
	OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (*FileItem, error)
	Rename(ctx context.Context, oldName, newName string) error
	RemoveAll(ctx context.Context, name string) error

	Enabled() bool
	Name() string
	WithIgnoreFn(ignoreFn func(Item) bool) Storage
	Path(name string) string

	List(ctx context.Context, name string) ([]Item, error)
	WriteTo(ctx context.Context, name string, reader io.Reader, opts WriteOpts) error
	ReadFrom(ctx context.Context, name string) (ReadAtSeekCloser, error)
	Walk(ctx context.Context, name string, walkFn func(Item) error) error
	UpdateDate(ctx context.Context, name string, date time.Time) error
	ConvertError(err error) error
}

type Time added in v1.6.1

type Time struct {
	time.Time
}

func (Time) ExtensionType added in v1.6.1

func (t Time) ExtensionType() int8

func (Time) Len added in v1.6.1

func (t Time) Len() int

func (Time) MarshalBinaryTo added in v1.6.1

func (t Time) MarshalBinaryTo(bytes []byte) error

func (*Time) UnmarshalBinary added in v1.6.1

func (t *Time) UnmarshalBinary(bytes []byte) error

type WriteOpts added in v1.0.2

type WriteOpts struct {
	Size int64
}

Jump to

Keyboard shortcuts

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