filesystem

package
v0.4.27 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DirectoryMode = FileMode(0o755)
	DefaultMode   = FileMode(0o644)
)

Functions

func ExifExtract added in v0.2.14

func ExifExtract(b []byte) (util.ValueMap, error)

func ImageType added in v0.2.14

func ImageType(path ...string) string

func MemFS added in v0.2.29

func MemFS() afero.Fs

func OSFS added in v0.2.29

func OSFS() afero.Fs

Types

type FileInfo added in v0.2.28

type FileInfo struct {
	Name  string
	Size  int64
	Mode  FileMode
	IsDir bool
}

func FileInfoFromDE added in v0.2.28

func FileInfoFromDE(e fs.DirEntry) *FileInfo

func FileInfoFromFS added in v0.2.28

func FileInfoFromFS(s fs.FileInfo) *FileInfo

func (FileInfo) Equal added in v0.2.28

func (i FileInfo) Equal(x *FileInfo) bool

type FileInfos added in v0.2.28

type FileInfos []*FileInfo

func FileInfosFromFS added in v0.2.28

func FileInfosFromFS(x []fs.FileInfo) FileInfos

func (FileInfos) Equal added in v0.2.28

func (f FileInfos) Equal(x FileInfos) bool

func (FileInfos) Sorted added in v0.2.28

func (f FileInfos) Sorted() FileInfos

type FileLoader

type FileLoader interface {
	Root() string
	Clone() FileLoader
	PeekFile(path string, maxSize int) ([]byte, error)
	Size(path string) int
	ReadFile(path string) ([]byte, error)
	FileReader(fn string) (Reader, error)
	CreateDirectory(path string) error
	WriteFile(path string, content []byte, mode FileMode, overwrite bool) error
	FileWriter(fn string, createIfNeeded bool, appendMode bool) (Writer, error)
	CopyFile(src string, tgt string) error
	CopyRecursive(src string, tgt string, ignore []string, logger util.Logger) error
	Move(src string, tgt string) error
	ListFiles(path string, ignore []string, logger util.Logger) FileInfos
	ListFilesRecursive(path string, ignore []string, logger util.Logger) ([]string, error)
	ListTree(cfg util.ValueMap, path string, ignore []string, logger util.Logger, tags ...string) (*Tree, error)
	ListJSON(path string, ignore []string, trimExtension bool, logger util.Logger) []string
	ListExtension(path string, ext string, ignore []string, trimExtension bool, logger util.Logger) []string
	ListDirectories(path string, ignore []string, logger util.Logger) []string
	Walk(path string, ign []string, fn func(fp string, info *FileInfo, err error) error) error
	Stat(path string) (*FileInfo, error)
	SetMode(path string, mode FileMode) error
	Exists(path string) bool
	IsDir(path string) bool
	Remove(path string, logger util.Logger) error
	RemoveRecursive(pt string, logger util.Logger) error
	Download(ctx context.Context, url string, path string, overwrite bool, logger util.Logger) (int, error)
	UnzipToDir(src string, dest string) (*util.OrderedMap[int64], error)
	String() string
}

type FileMode added in v0.2.28

type FileMode uint32

func (FileMode) ToFS added in v0.2.28

func (m FileMode) ToFS() fs.FileMode

type FileSystem

type FileSystem struct {
	Mode     string `json:"mode,omitempty"`
	ReadOnly bool   `json:"readOnly,omitempty"`
	// contains filtered or unexported fields
}

func NewFileSystem

func NewFileSystem(root string, readonly bool, mode string) (*FileSystem, error)

func (*FileSystem) Clone

func (f *FileSystem) Clone() FileLoader

func (*FileSystem) CopyFile

func (f *FileSystem) CopyFile(src string, tgt string) error

func (*FileSystem) CopyRecursive

func (f *FileSystem) CopyRecursive(src string, tgt string, ignore []string, logger util.Logger) error

func (*FileSystem) CreateDirectory

func (f *FileSystem) CreateDirectory(path string) error

func (*FileSystem) Download added in v0.3.9

func (f *FileSystem) Download(ctx context.Context, url string, path string, overwrite bool, _ util.Logger) (int, error)

func (*FileSystem) Exists

func (f *FileSystem) Exists(path string) bool

func (*FileSystem) FileReader added in v0.3.5

func (f *FileSystem) FileReader(fn string) (Reader, error)

func (*FileSystem) FileWriter added in v0.3.5

func (f *FileSystem) FileWriter(fn string, createIfNeeded bool, appendMode bool) (Writer, error)

func (*FileSystem) IsDir

func (f *FileSystem) IsDir(path string) bool

func (*FileSystem) ListDirectories

func (f *FileSystem) ListDirectories(path string, ign []string, logger util.Logger) []string

func (*FileSystem) ListExtension

func (f *FileSystem) ListExtension(path string, ext string, ign []string, trimExtension bool, logger util.Logger) []string

func (*FileSystem) ListFiles

func (f *FileSystem) ListFiles(path string, ign []string, logger util.Logger) FileInfos

func (*FileSystem) ListFilesRecursive

func (f *FileSystem) ListFilesRecursive(path string, ign []string, _ util.Logger) ([]string, error)

func (*FileSystem) ListJSON

func (f *FileSystem) ListJSON(path string, ign []string, trimExtension bool, logger util.Logger) []string

func (*FileSystem) ListTree added in v0.2.21

func (f *FileSystem) ListTree(cfg util.ValueMap, pth string, ign []string, logger util.Logger, tags ...string) (*Tree, error)

func (*FileSystem) Move

func (f *FileSystem) Move(src string, tgt string) error

func (*FileSystem) PeekFile

func (f *FileSystem) PeekFile(path string, maxSize int) ([]byte, error)

func (*FileSystem) ReadFile

func (f *FileSystem) ReadFile(path string) ([]byte, error)

func (*FileSystem) Remove

func (f *FileSystem) Remove(path string, logger util.Logger) error

func (*FileSystem) RemoveRecursive

func (f *FileSystem) RemoveRecursive(path string, logger util.Logger) error

func (*FileSystem) Root

func (f *FileSystem) Root() string

func (*FileSystem) SetMode added in v0.2.1

func (f *FileSystem) SetMode(path string, mode FileMode) error

func (*FileSystem) Size added in v0.2.21

func (f *FileSystem) Size(path string) int

func (*FileSystem) Stat

func (f *FileSystem) Stat(path string) (*FileInfo, error)

func (*FileSystem) String added in v0.2.28

func (f *FileSystem) String() string

func (*FileSystem) UnzipToDir added in v0.3.10

func (f *FileSystem) UnzipToDir(src string, dest string) (*util.OrderedMap[int64], error)

func (*FileSystem) Walk

func (f *FileSystem) Walk(path string, ign []string, fn func(fp string, info *FileInfo, err error) error) error

func (*FileSystem) WriteFile

func (f *FileSystem) WriteFile(path string, content []byte, mode FileMode, overwrite bool) error

type Node added in v0.2.21

type Node struct {
	Name     string   `json:"name"`
	Dir      bool     `json:"dir,omitempty"`
	Size     int      `json:"size,omitempty"`
	Children Nodes    `json:"children,omitempty"`
	Tags     []string `json:"tags,omitempty"`
}

func (*Node) Flatten added in v0.2.21

func (n *Node) Flatten(curr string) []string

func (*Node) Get added in v0.2.21

func (n *Node) Get(pth ...string) *Node

type Nodes added in v0.2.21

type Nodes []*Node

func (Nodes) Flatten added in v0.2.21

func (n Nodes) Flatten(curr string) []string

func (Nodes) Get added in v0.2.21

func (n Nodes) Get(pth ...string) *Node

func (Nodes) Merge added in v0.2.21

func (n Nodes) Merge(x Nodes) Nodes

func (Nodes) Sort added in v0.2.21

func (n Nodes) Sort() Nodes

type Reader added in v0.3.10

type Reader interface {
	io.Reader
	io.ReaderAt
	io.Closer
}

type Tree added in v0.2.21

type Tree struct {
	Nodes  Nodes         `json:"nodes,omitempty"`
	Config util.ValueMap `json:"config,omitempty"`
}

func (Tree) Flatten added in v0.2.21

func (t Tree) Flatten() []string

func (Tree) Merge added in v0.2.21

func (t Tree) Merge(x *Tree) *Tree

type Writer added in v0.3.10

type Writer interface {
	io.Writer
	io.WriterAt
	io.Closer
}

Jump to

Keyboard shortcuts

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