resource

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 20 Imported by: 2

README

resource

资源文件夹管理,基于 fsnotify 实现自动更新

Documentation

Index

Constants

View Source
const (
	Byte = "{Byte}"
	KB   = "{KB}"
	MB   = "{MB}"
	GB   = "{GB}"
	TB   = "{TB}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Anchor

type Anchor struct {
	// contains filtered or unexported fields
}

func (*Anchor) IsDir

func (a *Anchor) IsDir(f func(root, dir *Folder, name string, info os.FileInfo)) *Anchor

func (*Anchor) IsFile

func (a *Anchor) IsFile(f func(root *Folder, file *File, name string, info os.FileInfo)) *Anchor

type File

type File struct {
	Name string `cmps:"1"`
	Back *Folder
	Size
	// contains filtered or unexported fields
}

func (*File) Path

func (f *File) Path(file ...string) string

func (*File) String

func (f *File) String() string

type Folder

type Folder struct {
	File    `cmps:"1"`
	Files   cmps.SafeSlice[*File]
	Folders cmps.SafeSlice[*Folder]
}

func (*Folder) CD

func (f *Folder) CD(path string) *Folder

func (*Folder) Child

func (f *Folder) Child(path string) *Folder

func (*Folder) Create

func (f *Folder) Create(dirs []string) (size int64, isDir bool)

The dirs is used to describe the subdirectory under f.

func (*Folder) Delete

func (f *Folder) Delete(c interface{ Byte() int64 })

func (*Folder) Find

func (f *Folder) Find(name string) *File

func (*Folder) List

func (f *Folder) List() Chan.Chan[fmt.Stringer]

func (*Folder) Mkdir

func (f *Folder) Mkdir(path string) (*Folder, bool)

func (*Folder) String

func (f *Folder) String() string

func (*Folder) Touch

func (f *Folder) Touch(name string, size int64) (*File, bool)

func (*Folder) Transport

func (f *Folder) Transport(path string, names ...string) *Anchor

func (*Folder) Walk

func (f *Folder) Walk() int64

Use Walk() function when detect a new folder create or initialize *Folder.

type Resource

type Resource struct {
	event.AsyncEvent[fsnotify.Op]

	Root    *Folder
	Watcher *fsnotify.Watcher
	// contains filtered or unexported fields
}

func (*Resource) Init

func (r *Resource) Init(root string)

func (*Resource) OnEqual

func (r *Resource) OnEqual(cmd fsnotify.Op, handle func(name string)) func()

func (*Resource) Shell

func (r *Resource) Shell(name string)

type Size

type Size struct {
	// contains filtered or unexported fields
}

func (*Size) Add

func (s *Size) Add(size int64)

func (Size) Base

func (s Size) Base(base string) string

func (Size) Byte

func (s Size) Byte() int64

func (Size) Format

func (s Size) Format(f string, limit ...string) string

func (*Size) Set

func (s *Size) Set(size int64)

func (Size) String

func (s Size) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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