model

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DirectoryPerm = 0o700

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   uint32    `msg:"fileMode" json:"fileMode"`
	IsDirValue bool      `msg:"isDir" json:"isDir"`
}

func (*Item) DecodeMsg added in v1.6.0

func (z *Item) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Item) Dir

func (i Item) Dir() string

func (*Item) EncodeMsg added in v1.6.0

func (z *Item) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Item) IsDir

func (i Item) IsDir() bool

func (Item) IsZero added in v1.0.4

func (i Item) IsZero() bool

func (*Item) MarshalMsg added in v1.6.0

func (z *Item) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

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) Msgsize added in v1.6.0

func (z *Item) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

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

func (*Item) UnmarshalMsg added in v1.6.0

func (z *Item) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

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 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