filesystemlayer

package
v0.0.0-...-931a278 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("naza filesystemlayer: not found")

Functions

This section is empty.

Types

type FslDisk

type FslDisk struct {
}

func (*FslDisk) Create

func (f *FslDisk) Create(name string) (IFile, error)

func (*FslDisk) MkdirAll

func (f *FslDisk) MkdirAll(path string, perm uint32) error

func (*FslDisk) ReadFile

func (f *FslDisk) ReadFile(filename string) ([]byte, error)

func (*FslDisk) Remove

func (f *FslDisk) Remove(name string) error

func (*FslDisk) RemoveAll

func (f *FslDisk) RemoveAll(path string) error

func (*FslDisk) Rename

func (f *FslDisk) Rename(oldpath string, newpath string) error

func (*FslDisk) Type

func (f *FslDisk) Type() FslType

func (*FslDisk) WriteFile

func (f *FslDisk) WriteFile(filename string, data []byte, perm uint32) error

type FslMemory

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

func NewFslMemory

func NewFslMemory() *FslMemory

func (*FslMemory) Create

func (f *FslMemory) Create(name string) (IFile, error)

func (*FslMemory) MkdirAll

func (f *FslMemory) MkdirAll(path string, perm uint32) error

func (*FslMemory) ReadFile

func (f *FslMemory) ReadFile(filename string) ([]byte, error)

func (*FslMemory) Remove

func (f *FslMemory) Remove(name string) error

func (*FslMemory) RemoveAll

func (f *FslMemory) RemoveAll(path string) error

func (*FslMemory) Rename

func (f *FslMemory) Rename(oldpath string, newpath string) error

func (*FslMemory) Type

func (f *FslMemory) Type() FslType

func (*FslMemory) WriteFile

func (f *FslMemory) WriteFile(filename string, data []byte, perm uint32) error

type FslType

type FslType int
const (
	FslTypeDisk   FslType = 1
	FslTypeMemory         = 2
)

type IFile

type IFile interface {
	Write(b []byte) (n int, err error)
	Close() error
}

type IFileSystemLayer

type IFileSystemLayer interface {
	Type() FslType

	// 创建文件
	// 原始语义:如果文件已经存在,原文件内容被清空
	Create(name string) (IFile, error)

	Rename(oldpath string, newpath string) error
	MkdirAll(path string, perm uint32) error
	Remove(name string) error
	RemoveAll(path string) error

	ReadFile(filename string) ([]byte, error)
	WriteFile(filename string, data []byte, perm uint32) error
}
var (
	DefaultDiskFileSystemLayer   IFileSystemLayer
	DefaultMemoryFileSystemLayer IFileSystemLayer
)

func FslFactory

func FslFactory(t FslType) IFileSystemLayer

Jump to

Keyboard shortcuts

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