model

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 12 Imported by: 13

Documentation

Index

Constants

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

	ReadFlag  = os.O_RDONLY
	WriteFlag = os.O_RDWR | os.O_CREATE | os.O_TRUNC
)

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 File added in v1.7.0

type File interface {
	ReadAtSeekCloser
	io.Writer
	Readdir(int) ([]fs.FileInfo, error)
	Stat() (fs.FileInfo, error)
}

type Item

type Item struct {
	Date       time.Time   `json:"date"      msg:"date"`
	ID         string      `json:"id"        msg:"id"`
	NameValue  string      `json:"name"      msg:"name"`
	Pathname   string      `json:"pathname"  msg:"pathname"`
	Extension  string      `json:"extension" msg:"extension"`
	SizeValue  int64       `json:"size"      msg:"size"`
	FileMode   os.FileMode `json:"fileMode"  msg:"fileMode"`
	IsDirValue bool        `json:"isDir"     msg:"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
	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