fs

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 10 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileIO

type FileIO interface {
	Path() Path
	WriteText(text string, opt *Options, mkdirs bool) error
	WriteBinary(data []byte, opt *Options, mkdirs bool) error
	ReadText(opt *Options) (string, error)
	ReadBinary(opt *Options) ([]byte, error)
	OpenReader(opt *Options) (io.ReadCloser, error)
	OpenWriter(opt *Options, mkdirs bool) (io.WriteCloser, error)
}

FileIO 表示对一个具体文件的IO

type FileMeta

type FileMeta interface {
	LastModTime() int64
	Mode() os.FileMode
	Size() int64

	IsFile() bool
	IsDir() bool
	IsSymlink() bool
	Exists() bool
	CanExecute() bool
	CanRead() bool
	CanWrite() bool
}

FileMeta 表示对一个具体文件的 posix liked mode

type FileSystem

type FileSystem interface {
	Roots() []Path
	Resolve(path string) (Path, error)
	GetPath(path string) Path
	GetPathByURI(uri lang.URI) (Path, error)
	IsAbsolute(path string) bool

	Separator() string
	SeparatorChar() rune
	PathSeparator() string
	PathSeparatorChar() rune

	DefaultReadOptions() *Options
	DefaultWriteOptions() *Options
	SetDefaultOptions(r *Options, w *Options)
}

FileSystem 代表一个抽象的文件系统

func Default

func Default() FileSystem

Default 创建一个默认的 FileSystem 实例

type Options added in v0.0.34

type Options struct {
	Create bool
	Flag   int
	Mode   os.FileMode
}

Options 包含文件系统IO的选项

func (*Options) Clone added in v0.0.37

func (inst *Options) Clone() *Options

Clone 返回一个Options的副本

func (*Options) Normalize added in v0.0.34

func (inst *Options) Normalize() *Options

Normalize 返回一个正常的Options

type Path

type Path interface {
	URI() lang.URI
	String() string
	Parent() Path
	FileSystem() FileSystem

	Path() string
	Name() string
	Exists() bool
	IsDir() bool
	IsFile() bool
	IsSymlink() bool
	LastModTime() int64 // ms from unix time(1970-01-01 00:00:00)
	GetMeta() FileMeta

	SetMeta(meta FileMeta) error
	SetMode(mode os.FileMode) error
	SetLastModTime(t int64) error // ms from unix time(1970-01-01 00:00:00)
	Delete() error

	Size() int64

	GetIO() FileIO

	CreateFile(opt *Options) error
	CreateFileWithSize(size int64, opt *Options) error

	CopyTo(target Path) error
	MoveTo(target Path) error

	Mkdir() error
	Mkdirs() error

	ListNames() []string // 返回短文件名
	ListPaths() []string // 返回完整路径名
	ListItems() []Path

	GetChild(name string) Path
	GetHref(name string) Path
}

Path 代表一个路径

Jump to

Keyboard shortcuts

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