filesystem

package
v0.0.0-...-a57500f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpFileSystem

func HttpFileSystem(fs FileSystem, key ...string) http.FileSystem

Types

type CacheFileCreateParams

type CacheFileCreateParams struct {
	Id   FileId
	Key  string
	Flag int
}

type CacheFileOpenParams

type CacheFileOpenParams struct {
	Id  FileId
	Key string
}

type CreateParams

type CreateParams struct {
	ParentId string
	Name     string
	Flag     int
}

type File

type File interface {
	RegularFile
	Cache() FileCache
}

A File is a RegularFile with cache support and is returned by a FileSystem's Open method.

type FileCache

type FileCache interface {
	PutBool(key string, value bool) error
	GetBool(key string) (bool, error)
	PutString(key string, value string) error
	GetString(key string) (string, error)

	Create(key string, flag int) (RegularFile, error)
	Open(key string) (RegularFile, error)
}

type FileId

type FileId int

FileId is marshallable file identifier

type FileInfo

type FileInfo interface {
	os.FileInfo
	Id() string
	MimeType() string
}

type FileInfoStruct

type FileInfoStruct struct {
	AName     string
	ASize     int64
	AMode     os.FileMode
	AModTime  time.Time
	AIsDir    bool
	AId       string
	AMimeType string
}

type FileSystem

type FileSystem interface {
	Open(id string) (File, error)
	Create(parentId string, name string, flag int) (File, error)
	Mkdir(parentId string, name string, perm os.FileMode) (string, error)
	RemoveAll(id string) error
	Rename(oldId, newParentId string, newName string) (string, error)
	Stat(id string) (FileInfo, error)
}

A FileSystem implements access to a collection of named files. The elements in a file path are separated by slash ('/', U+002F) characters, regardless of host operating system convention.

type GetCacheValueParams

type GetCacheValueParams struct {
	Id  FileId
	Key string
}

type MkdirParams

type MkdirParams struct {
	ParentId string
	Name     string
	Perm     os.FileMode
}

type PutBoolParams

type PutBoolParams struct {
	Id    FileId
	Key   string
	Value bool
}

type PutStringParams

type PutStringParams struct {
	Id    FileId
	Key   string
	Value string
}

type ReadParams

type ReadParams struct {
	Id      FileId
	BufSize int
}

type ReadReturnParams

type ReadReturnParams struct {
	Buf []byte
	N   int
}

type ReaddirParams

type ReaddirParams struct {
	Id    FileId
	Count int
}

type RegularFile

type RegularFile interface {
	Id() string
	ParentId() string
	io.Reader
	io.Writer
	io.Closer
	io.Seeker
	Sync() error
	Stat() (FileInfo, error)
	Readdir(count int) ([]FileInfo, error)
}

A RegularFile represents an open file descriptor. The methods should behave the same as those on an *os.File.

type RenameParams

type RenameParams struct {
	OldId       string
	NewParentId string
	NewName     string
}

type SeekParams

type SeekParams struct {
	Id     FileId
	Offset int64
	Whence int
}

type WriteParams

type WriteParams struct {
	Id  FileId
	Buf []byte
}

Jump to

Keyboard shortcuts

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