afs

package module
v0.0.0-...-ee80a08 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 3 Imported by: 0

README

afs

AFS(Abstract File System)提供一组抽象的文件系统API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultFSFactory

func SetDefaultFSFactory(factory FileSystemFactory) error

SetDefaultFSFactory 在调用 Default() 之前,必须设置默认的工厂

Types

type FS

type FS interface {
	NewPath(path string) Path

	ListRoots() []Path

	CreateTempFile(prefix, suffix string, dir Path) (Path, error)

	// PathSeparator return ';'(windows) | ':'(unix)
	PathSeparator() string

	// Separator return '/'(unix) | '\'(windows)
	Separator() string
}

FS 是表示文件系统的接口

func Default

func Default() FS

Default 获取默认的FS对象

type FileIO

type FileIO interface {
	Path() Path
}

FileIO ...

type FileInfo

type FileInfo interface {
	Path() Path

	Length() int64

	CreatedAt() time.Time

	UpdatedAt() time.Time

	Mode() fs.FileMode

	Exists() bool

	IsFile() bool

	IsDirectory() bool
}

FileInfo ...

type FileSystemFactory

type FileSystemFactory interface {
	Create() FS
}

FileSystemFactory 是用来创建 FS 对象的工厂

type Options

type Options struct {
	Permission fs.FileMode
}

Options ...

type Path

type Path interface {
	GetFS() FS

	GetParent() Path

	GetChild(name string) Path

	String() string

	GetName() string

	GetInfo() FileInfo

	GetIO() FileIO

	Mkdir(op Options) error

	Mkdirs(op Options) error

	Delete() error

	ListNames() []string

	ListPaths() []string

	ListChildren() []Path
}

Path 是表示绝对路径的接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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