fs

package
v0.0.0-...-6a6267a Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 6 Imported by: 4

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, mode IoMode) error
	WriteBinary(data []byte, mode IoMode) error
	ReadText() (string, error)
	ReadBinary() ([]byte, error)
}

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

type FileMeta

type FileMeta interface {
	LastModTime() int64
	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
	GetPath(path string) Path
	Separator() string
	SeparatorChar() rune
	PathSeparator() string
	PathSeparatorChar() rune
}

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

func Default

func Default() FileSystem

Default 创建一个默认的 FileSystem 实例

type IoMode

type IoMode interface {
	Flag() int
	Perm() os.FileMode
}

IoMode 执行文件IO操作的模式

type Path

type Path interface {
	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)

	Delete() error

	Size() int64

	GetIO() FileIO

	CreateFile(mode IoMode) error
	CreateFileWithSize(size int64, mode IoMode) error

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

	Mkdir() error
	Mkdirs() error

	GetNameList() []string // 返回短文件名
	GetPathList() []string // 返回完整路径名
	GetItemList() []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