filesystem

package
v1.0.1010 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Directory

type Directory struct {
	Handler
}

*

  • 文件管理器文件夹操作扩展 *
  • @create 2021-8-1
  • @author deatil

func NewDirectory

func NewDirectory(filesystem *Filesystem, path ...string) *Directory

new 文件管理器

func (*Directory) Delete

func (this *Directory) Delete() (bool, error)

删除文件夹

func (*Directory) GetContents

func (this *Directory) GetContents(recursive ...bool) ([]map[string]any, error)

列出文件

func (*Directory) WithFilesystem added in v1.0.1007

func (this *Directory) WithFilesystem(filesystem *Filesystem) *Directory

设置管理器

func (*Directory) WithPath added in v1.0.1007

func (this *Directory) WithPath(path string) *Directory

设置目录

type File

type File struct {
	Handler
}

*

  • 文件管理扩展 *
  • @create 2021-8-1
  • @author deatil

func NewFile

func NewFile(filesystem *Filesystem, path ...string) *File

new 文件管理器

func (*File) Copy

func (this *File) Copy(newpath string) (*File, error)

复制

func (*File) Delete

func (this *File) Delete() (bool, error)

删除

func (*File) Exists

func (this *File) Exists() bool

存在

func (*File) GetMetadata

func (this *File) GetMetadata() (map[string]any, error)

数据

func (*File) GetMimetype

func (this *File) GetMimetype() (string, error)

文件类型

func (*File) GetSize

func (this *File) GetSize() (int64, error)

大小

func (*File) GetTimestamp

func (this *File) GetTimestamp() (int64, error)

时间戳

func (*File) GetVisibility

func (this *File) GetVisibility() (string, error)

权限

func (*File) Put

func (this *File) Put(content []byte) (bool, error)

导入字节

func (*File) PutStream

func (this *File) PutStream(resource *os.File) (bool, error)

导入文件流

func (*File) Read

func (this *File) Read() ([]byte, error)

读取

func (*File) ReadStream

func (this *File) ReadStream() (*os.File, error)

读取成文件流

func (*File) Rename

func (this *File) Rename(newpath string) (bool, error)

重命名

func (*File) Update

func (this *File) Update(content []byte) (bool, error)

更新字节

func (*File) UpdateStream

func (this *File) UpdateStream(resource io.Reader) (bool, error)

更新文件流

func (*File) WithFilesystem added in v1.0.1007

func (this *File) WithFilesystem(filesystem *Filesystem) *File

设置管理器

func (*File) WithPath added in v1.0.1007

func (this *File) WithPath(path string) *File

设置目录

func (*File) Write

func (this *File) Write(content []byte) (bool, error)

写入字节

func (*File) WriteStream

func (this *File) WriteStream(resource io.Reader) (bool, error)

写入文件流

type Filesystem added in v1.0.1007

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

*

  • 文件管理器
  • Filesystem struct *
  • @create 2021-8-1
  • @author deatil

func New

func New(adapter interfaces.Adapter, conf ...map[string]any) *Filesystem

文件管理器 return a *Filesystem

func (*Filesystem) Append added in v1.0.1007

func (this *Filesystem) Append(path string, contents []byte, conf ...map[string]any) (bool, error)

尾部添加 Append contents

func (*Filesystem) AppendStream added in v1.0.1007

func (this *Filesystem) AppendStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

尾部添加数据流 Append resource Stream

func (*Filesystem) Copy added in v1.0.1007

func (this *Filesystem) Copy(path string, newpath string) (bool, error)

复制 Copy path

func (*Filesystem) CreateDir added in v1.0.1007

func (this *Filesystem) CreateDir(dirname string, conf ...map[string]any) (bool, error)

创建文件夹 Create Dir

func (*Filesystem) Delete added in v1.0.1007

func (this *Filesystem) Delete(path string) (bool, error)

删除 Delete path

func (*Filesystem) DeleteDir added in v1.0.1007

func (this *Filesystem) DeleteDir(dirname string) (bool, error)

删除文件夹 Delete Dir

func (*Filesystem) Get added in v1.0.1007

func (this *Filesystem) Get(path string, handler ...func(*Filesystem, string) any) any

获取 Get file := Get("/file.txt").(*File) dir := Get("/dir").(*Directory)

func (*Filesystem) GetAdapter added in v1.0.1007

func (this *Filesystem) GetAdapter() interfaces.Adapter

获取适配器 Get Adapter

func (*Filesystem) GetConfig added in v1.0.1007

func (this *Filesystem) GetConfig() interfaces.Config

获取配置 Get Config

func (*Filesystem) GetMetadata added in v1.0.1007

func (this *Filesystem) GetMetadata(path string) (map[string]any, error)

信息数据 Get Metadata

func (*Filesystem) GetMimetype added in v1.0.1007

func (this *Filesystem) GetMimetype(path string) (string, error)

类型 GetMimetype

func (*Filesystem) GetSize added in v1.0.1007

func (this *Filesystem) GetSize(path string) (int64, error)

大小 GetSize

func (*Filesystem) GetTimestamp added in v1.0.1007

func (this *Filesystem) GetTimestamp(path string) (int64, error)

时间戳 GetTimestamp

func (*Filesystem) GetVisibility added in v1.0.1007

func (this *Filesystem) GetVisibility(path string) (string, error)

权限 GetVisibility string

func (*Filesystem) Has added in v1.0.1007

func (this *Filesystem) Has(path string) bool

判断 return true if path exists, else false

func (*Filesystem) ListContents added in v1.0.1007

func (this *Filesystem) ListContents(dirname string, recursive ...bool) ([]map[string]any, error)

列表 ListContents

func (*Filesystem) PrepareConfig added in v1.0.1007

func (this *Filesystem) PrepareConfig(settings map[string]any) interfaces.Config

提前设置配置 Prepare Config

func (*Filesystem) Prepend added in v1.0.1007

func (this *Filesystem) Prepend(path string, contents []byte, conf ...map[string]any) (bool, error)

文件头添加 Prepend contents

func (*Filesystem) PrependStream added in v1.0.1007

func (this *Filesystem) PrependStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

文件头添加数据流 Prepend resource Stream

func (*Filesystem) Put added in v1.0.1007

func (this *Filesystem) Put(path string, contents []byte, conf ...map[string]any) (bool, error)

更新 Put contents to path

func (*Filesystem) PutStream added in v1.0.1007

func (this *Filesystem) PutStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

更新数据流 Put stream resource to path

func (*Filesystem) Read added in v1.0.1007

func (this *Filesystem) Read(path string) ([]byte, error)

文件到字符 Read bytes

func (*Filesystem) ReadAndDelete added in v1.0.1007

func (this *Filesystem) ReadAndDelete(path string) ([]byte, error)

读取并删除 read and delete

func (*Filesystem) ReadStream added in v1.0.1007

func (this *Filesystem) ReadStream(path string) (*os.File, error)

读取成数据流 Read and return Stream

func (*Filesystem) Rename added in v1.0.1007

func (this *Filesystem) Rename(path string, newpath string) (bool, error)

重命名 Rename path

func (*Filesystem) SetVisibility added in v1.0.1007

func (this *Filesystem) SetVisibility(path string, visibility string) (bool, error)

设置权限 SetVisibility

func (*Filesystem) Update added in v1.0.1007

func (this *Filesystem) Update(path string, contents []byte, conf ...map[string]any) (bool, error)

更新字符 Update

func (*Filesystem) UpdateStream added in v1.0.1007

func (this *Filesystem) UpdateStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

更新数据流 Update Stream

func (*Filesystem) WithAdapter added in v1.0.1007

func (this *Filesystem) WithAdapter(adapters interfaces.Adapter) *Filesystem

设置适配器 With Adapter

func (*Filesystem) WithConfig added in v1.0.1007

func (this *Filesystem) WithConfig(conf interfaces.Config)

设置配置 With Config

func (*Filesystem) Write added in v1.0.1007

func (this *Filesystem) Write(path string, contents []byte, conf ...map[string]any) (bool, error)

写入文件 Write contents to path

func (*Filesystem) WriteStream added in v1.0.1007

func (this *Filesystem) WriteStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

写入数据流 Write stream resource to path

type Handler

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

*

  • 扩展基础类 *
  • @create 2021-8-1
  • @author deatil

func (*Handler) GetFilesystem

func (this *Handler) GetFilesystem() *Filesystem

获取文件系统

func (*Handler) GetPath

func (this *Handler) GetPath() string

获取目录

func (*Handler) GetType

func (this *Handler) GetType() string

类型

func (*Handler) IsDir

func (this *Handler) IsDir() bool

是否为文件夹

func (*Handler) IsFile

func (this *Handler) IsFile() bool

是否为文件

func (*Handler) SetFilesystem

func (this *Handler) SetFilesystem(filesystem *Filesystem) any

设置文件系统

func (*Handler) SetPath

func (this *Handler) SetPath(path string) any

设置目录

type MountManager

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

*

  • 文件系统 *
  • @create 2021-8-7
  • @author deatil

func NewMountManager

func NewMountManager(filesystems ...map[string]any) *MountManager

文件系统实例化

func (*MountManager) Copy

func (this *MountManager) Copy(from string, to string, conf ...map[string]any) (bool, error)

复制

func (*MountManager) CreateDir

func (this *MountManager) CreateDir(dirname string, conf ...map[string]any) (bool, error)

创建文件夹

func (*MountManager) Delete

func (this *MountManager) Delete(path string) (bool, error)

删除

func (*MountManager) DeleteDir

func (this *MountManager) DeleteDir(dirname string) (bool, error)

删除文件夹

func (*MountManager) FilterPrefix

func (this *MountManager) FilterPrefix(arguments []string) (string, []string)

过滤 [:prefix, :arguments]

func (*MountManager) Get

func (this *MountManager) Get(path string, handler ...func(*Filesystem, string) any) any

获取 file := Get("/file.txt").(*File) dir := Get("/dir").(*Directory)

func (*MountManager) GetFilesystem

func (this *MountManager) GetFilesystem(prefix string) *Filesystem

获取文件管理器

func (*MountManager) GetMetadata

func (this *MountManager) GetMetadata(path string) (map[string]any, error)

信息数据

func (*MountManager) GetMimetype

func (this *MountManager) GetMimetype(path string) (string, error)

类型

func (*MountManager) GetPrefixAndPath

func (this *MountManager) GetPrefixAndPath(path string) (string, string)

获取前缀和路径 [:prefix, :path]

func (*MountManager) GetSize

func (this *MountManager) GetSize(path string) (int64, error)

大小

func (*MountManager) GetTimestamp

func (this *MountManager) GetTimestamp(path string) (int64, error)

时间戳

func (*MountManager) GetVisibility

func (this *MountManager) GetVisibility(path string) (string, error)

权限

func (*MountManager) Has

func (this *MountManager) Has(path string) bool

判断

func (*MountManager) ListContents

func (this *MountManager) ListContents(directory string, recursive ...bool) ([]map[string]any, error)

列出内容

func (*MountManager) MountFilesystem

func (this *MountManager) MountFilesystem(prefix string, filesystem *Filesystem) *MountManager

单独

func (*MountManager) MountFilesystems

func (this *MountManager) MountFilesystems(filesystems map[string]any) *MountManager

批量

func (*MountManager) Move

func (this *MountManager) Move(from string, to string, conf ...map[string]any) (bool, error)

移动

func (*MountManager) Put

func (this *MountManager) Put(path string, contents []byte, conf ...map[string]any) (bool, error)

更新

func (*MountManager) PutStream

func (this *MountManager) PutStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

更新数据流

func (*MountManager) Read

func (this *MountManager) Read(path string) ([]byte, error)

文件到字符

func (*MountManager) ReadAndDelete

func (this *MountManager) ReadAndDelete(path string) (any, error)

读取并删除

func (*MountManager) ReadStream

func (this *MountManager) ReadStream(path string) (*os.File, error)

读取成数据流

func (*MountManager) Rename

func (this *MountManager) Rename(path string, newpath string) (bool, error)

重命名

func (*MountManager) SetVisibility

func (this *MountManager) SetVisibility(path string, visibility string) (bool, error)

设置权限

func (*MountManager) Update

func (this *MountManager) Update(path string, contents []byte, conf ...map[string]any) (bool, error)

更新字符

func (*MountManager) UpdateStream

func (this *MountManager) UpdateStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

更新数据流

func (*MountManager) Write

func (this *MountManager) Write(path string, contents []byte, conf ...map[string]any) (bool, error)

写入文件

func (*MountManager) WriteStream

func (this *MountManager) WriteStream(path string, resource io.Reader, conf ...map[string]any) (bool, error)

写入数据流

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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