model

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 12 Imported by: 6 modules, 16 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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

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

Variables

View Source
var (
	ErrNotEnabled   = errors.New("not enabled")
	ErrRelativePath = errors.New("name contains relatives paths")
	ErrInvalidPath  = errors.New("name is invalid")
	ErrDirExpected  = errors.New("directory expected")
	ErrUnsupported  = fmt.Errorf("not supported by the storage: %w", errors.ErrUnsupported)
)

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 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) SortKey added in v1.8.0

func (i Item) SortKey() string

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 {
	Enabled() bool
	Close() error
	Path(string) string

	Stat(ctx context.Context, name string) (Item, error)
	Mkdir(ctx context.Context, name string) error
	Rename(ctx context.Context, oldName, newName string) error
	RemoveAll(ctx context.Context, name string) error

	Name() string
	WithIgnoreFn(func(Item) bool) Storage

	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