filesystemV4

package
v1.63.7 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInit         = fmt.Errorf("获取文件或目录信息失败")
	ErrMissFullPath = fmt.Errorf("文件或目录完整路径不能为空")
	ErrRename       = fmt.Errorf("修改文件名失败")
	ErrRemove       = fmt.Errorf("删除文件失败")
	ErrFileNotExist = fmt.Errorf("文件不存在")
	ErrCreateFile   = fmt.Errorf("创建文件失败")
	ErrWriteFile    = fmt.Errorf("写入文件失败")
	ErrReadFile     = fmt.Errorf("读取文件失败")
	ErrOpenFile     = fmt.Errorf("打开文件失败")
	ErrDirNotExist  = fmt.Errorf("目录不存在")
	ErrCreateDir    = fmt.Errorf("创建目录失败")
	ErrReadDir      = fmt.Errorf("读取目录失败")
)
View Source
var (
	DefaultCreateMode = os.O_APPEND | os.O_CREATE | os.O_WRONLY
	DefaultReadMode   = os.O_RDWR
)

Functions

This section is empty.

Types

type AttrFlag added in v1.61.0

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

func (AttrFlag) Register added in v1.61.0

func (my AttrFlag) Register(o *Operation)

type AttrMode added in v1.61.0

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

func (AttrMode) Register added in v1.61.0

func (my AttrMode) Register(o *Operation)

type AttrPath added in v1.61.0

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

func (AttrPath) Register added in v1.61.0

func (my AttrPath) Register(f Filesystemer)

type Dir

type Dir struct {
	Error    error       `json:"error"`    // 错误信息
	Name     string      `json:"name"`     // 文件名
	BasePath string      `json:"basePath"` // 基础路径
	FullPath string      `json:"fullPath"` // 完整路径
	Size     int64       `json:"size"`     // 文件大小
	Info     os.FileInfo `json:"info"`     // 文件信息
	Mode     os.FileMode `json:"mode"`     // 文件权限
	Exist    bool        `json:"exist"`    // 文件是否存在

	Files []Filesystemer `json:"files"` // 目录下的文件列表
	Dirs  []Filesystemer `json:"dirs"`  // 子目录列表
	Kind  string         `json:"kind"`  // 类型
	// contains filtered or unexported fields
}

func (*Dir) Copy

func (my *Dir) Copy() Filesystemer

Copy 复制当前对象

func (*Dir) CopyDirsTo

func (my *Dir) CopyDirsTo(isRel bool, dstPaths ...string) *Dir

CopyTo 复制当前目录下的所有子目录到目标路径

func (*Dir) CopyFilesTo

func (my *Dir) CopyFilesTo(isRel bool, dstPaths ...string) *Dir

CopyFilesTo 复制当前目录下的所有文件到目标路径

func (*Dir) CopyTo added in v1.61.0

func (my *Dir) CopyTo(isRel bool, dstPaths ...string) Filesystemer

CopyAllTo 复制当前目录下的所有文件和子目录到目标路径

func (*Dir) Create

func (my *Dir) Create(attrs ...OperationAttributer) Filesystemer

Create 创建多级目录

func (*Dir) GetDirs added in v1.61.1

func (my *Dir) GetDirs() []Filesystemer

func (*Dir) GetError added in v1.61.0

func (my *Dir) GetError() error

func (*Dir) GetExist added in v1.61.0

func (my *Dir) GetExist() bool

func (*Dir) GetFiles added in v1.61.1

func (my *Dir) GetFiles() []Filesystemer

func (*Dir) GetFullPath added in v1.61.0

func (my *Dir) GetFullPath() string

func (*Dir) GetInfo added in v1.61.0

func (my *Dir) GetInfo() os.FileInfo

func (*Dir) ImplFilesystemer added in v1.61.0

func (*Dir) ImplFilesystemer()

func (*Dir) Join

func (my *Dir) Join(paths ...string) Filesystemer

func (*Dir) LS

func (my *Dir) LS() Filesystemer

LS 列出当前目录下的所有文件和子目录

func (*Dir) Lock

func (my *Dir) Lock() Filesystemer

Lock 加锁 → 写

func (*Dir) RLock

func (my *Dir) RLock() Filesystemer

RLock 加锁 → 读

func (*Dir) RUnlock

func (my *Dir) RUnlock() Filesystemer

RUnlock 解锁 → 读

func (*Dir) Remove

func (my *Dir) Remove() Filesystemer

Remove 删除目录

func (*Dir) RemoveAll

func (my *Dir) RemoveAll() Filesystemer

RemoveAll 递归删除目录

func (*Dir) Rename

func (my *Dir) Rename(newName string) Filesystemer

Rename 重命名目录

func (*Dir) SetAttrs added in v1.61.0

func (my *Dir) SetAttrs(attrs ...PathAttributer) Filesystemer

func (*Dir) SetFullPathByAttr added in v1.61.0

func (my *Dir) SetFullPathByAttr(attrs ...PathAttributer) Filesystemer

func (*Dir) SetFullPathForAttr added in v1.61.0

func (my *Dir) SetFullPathForAttr(path string) Filesystemer

func (*Dir) Unlock

func (my *Dir) Unlock() Filesystemer

Unlock 解锁 → 写

func (*Dir) Up

func (my *Dir) Up() Filesystemer

Up 向上一级目录

type File

type File struct {
	Error    error       `json:"error"`    // 错误信息
	Name     string      `json:"name"`     // 文件名
	BasePath string      `json:"basePath"` // 基础路径
	FullPath string      `json:"fullPath"` // 完整路径
	Size     int64       `json:"size"`     // 文件大小
	Info     os.FileInfo `json:"info"`     // 文件信息
	Mode     os.FileMode `json:"mode"`     // 文件权限
	Exist    bool        `json:"exist"`    // 文件是否存在

	Ext      string      `json:"extension"` // 文件扩展名
	FileInfo os.FileInfo `json:"fileInfo"`  // 文件信息
	Mime     string      `json:"mime"`      // 文件 Mime 类型
	Kind     string      `json:"kind"`      // 类型
	// contains filtered or unexported fields
}

func (*File) Copy

func (my *File) Copy() Filesystemer

func (*File) CopyTo

func (my *File) CopyTo(isRel bool, dstPaths ...string) Filesystemer

CopyTo 复制文件到指定路径

func (*File) Create

func (my *File) Create(attrs ...OperationAttributer) Filesystemer

Create 创建文件

func (*File) GetDirs added in v1.61.1

func (my *File) GetDirs() []Filesystemer

func (*File) GetError added in v1.61.0

func (my *File) GetError() error

func (*File) GetExist added in v1.61.0

func (my *File) GetExist() bool

func (*File) GetFiles added in v1.61.1

func (my *File) GetFiles() []Filesystemer

func (*File) GetFullPath added in v1.61.0

func (my *File) GetFullPath() string

func (*File) GetInfo added in v1.61.0

func (my *File) GetInfo() os.FileInfo

func (*File) ImplFilesystemer added in v1.61.0

func (*File) ImplFilesystemer()

func (*File) Join

func (my *File) Join(paths ...string) Filesystemer

func (*File) LS added in v1.61.1

func (my *File) LS() Filesystemer

func (*File) Lock

func (my *File) Lock() Filesystemer

Lock 加锁 → 写

func (*File) RLock

func (my *File) RLock() Filesystemer

RLock 加锁 → 读

func (*File) RUnlock

func (my *File) RUnlock() Filesystemer

RUnlock 解锁 → 读

func (*File) Read

func (my *File) Read(attrs ...OperationAttributer) ([]byte, error)

Read 读取文件内容

func (*File) Remove

func (my *File) Remove() Filesystemer

Remove 删除文件

func (*File) Rename

func (my *File) Rename(newName string) Filesystemer

Rename 重命名文件

func (*File) SetAttrs added in v1.61.0

func (my *File) SetAttrs(attrs ...PathAttributer) Filesystemer

func (*File) SetFullPathByAttr added in v1.61.0

func (my *File) SetFullPathByAttr(attrs ...PathAttributer) Filesystemer

func (*File) SetFullPathForAttr added in v1.61.0

func (my *File) SetFullPathForAttr(path string) Filesystemer

func (*File) Unlock

func (my *File) Unlock() Filesystemer

Unlock 解锁 → 写

func (*File) Up added in v1.61.0

func (my *File) Up() Filesystemer

func (*File) Write

func (my *File) Write(content []byte, attrs ...OperationAttributer) Filesystemer

向文件内写入内容

type Filesystemer added in v1.61.0

type Filesystemer interface {
	ImplFilesystemer()
	GetExist() bool
	GetError() error
	GetFullPath() string
	GetInfo() os.FileInfo
	GetDirs() []Filesystemer
	GetFiles() []Filesystemer
	SetAttrs(attrs ...PathAttributer) Filesystemer
	SetFullPathForAttr(path string) Filesystemer
	SetFullPathByAttr(attrs ...PathAttributer) Filesystemer

	Lock() Filesystemer
	Unlock() Filesystemer
	RLock() Filesystemer
	RUnlock() Filesystemer
	Join(paths ...string) Filesystemer
	Create(attrs ...OperationAttributer) Filesystemer
	Rename(newName string) Filesystemer
	Remove() Filesystemer
	CopyTo(isRel bool, dstPaths ...string) Filesystemer
	Copy() Filesystemer
	Up() Filesystemer
	LS() Filesystemer
	// contains filtered or unexported methods
}

func NewDir added in v1.61.0

func NewDir(attrs ...PathAttributer) Filesystemer

func NewFile added in v1.61.0

func NewFile(attrs ...PathAttributer) Filesystemer

type Operation added in v1.61.0

type Operation struct {
	Flag int
	Mode os.FileMode
}

func NewOperation added in v1.61.0

func NewOperation(attrs ...OperationAttributer) *Operation

func (*Operation) SetAttrs added in v1.61.0

func (my *Operation) SetAttrs(attrs ...OperationAttributer) *Operation

type OperationAttributer added in v1.61.0

type OperationAttributer interface{ Register(o *Operation) }

func Flag added in v1.61.0

func Flag(flag int) OperationAttributer

func Mode added in v1.61.0

func Mode(mode os.FileMode) OperationAttributer

type PathAttributer added in v1.61.0

type PathAttributer interface{ Register(f Filesystemer) }

func Abs added in v1.61.0

func Abs(paths ...string) PathAttributer

func Rel added in v1.61.0

func Rel(paths ...string) PathAttributer

Jump to

Keyboard shortcuts

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