fs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileIO = &iofs{}

FileIO is a file system backed by the io package.

View Source
var Mem = &memfs{files: map[string]*MemFile{}}

Mem is a file system backed by memory.

Functions

This section is empty.

Types

type File

type File interface {
	io.Closer
	io.ReaderAt
	io.WriterAt

	Stat() (os.FileInfo, error)
	Sync() error
	Truncate(size int64) error
}

File is the interface compatible with os.File.

type FileManager

type FileManager interface {
	File
	Type() string
	Slice(start int64, end int64) ([]byte, error)
}

FileManager is an interface to support different types of storage such file based storage or a memory-mapped file storage.

type FileSystem

type FileSystem interface {
	OpenFile(name string, flag int, perm os.FileMode) (FileManager, error)
	CreateLockFile(name string) (LockFile, error)
	Stat(name string) (os.FileInfo, error)
	Remove(name string) error
}

FileSystem represents a virtual file system.

type IOFile

type IOFile struct {
	*os.File
}

IOFile is file system based store for DB

func (*IOFile) Close

func (f *IOFile) Close() error

Close closes file on DB close

func (*IOFile) ReadAt

func (f *IOFile) ReadAt(p []byte, off int64) (int, error)

ReadAt reads data from file at offset

func (*IOFile) Slice

func (f *IOFile) Slice(start int64, end int64) ([]byte, error)

Slice provide the data for start and end offset

func (*IOFile) Sync

func (f *IOFile) Sync() error

Sync flush the changes from file to disk

func (*IOFile) Type

func (f *IOFile) Type() string

Type indicate type of filesystem

func (*IOFile) WriteAt

func (f *IOFile) WriteAt(p []byte, off int64) (int, error)

WriteAt writes data to file at the given offset

type LockFile

type LockFile interface {
	Unlock() error
}

LockFile represents a lock file.

type MemFile

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

MemFile mem file is used to write buffer to memory store

func (*MemFile) Close

func (m *MemFile) Close() error

Close closes memtable on DB close

func (*MemFile) IsDir

func (m *MemFile) IsDir() bool

IsDir indicates if the path is directory

func (*MemFile) ModTime

func (m *MemFile) ModTime() time.Time

ModTime modtime for memtable

func (*MemFile) Mode

func (m *MemFile) Mode() os.FileMode

Mode mode of FileSystem

func (*MemFile) Name

func (m *MemFile) Name() string

Name name of the FileSystem

func (*MemFile) ReadAt

func (m *MemFile) ReadAt(p []byte, off int64) (int, error)

ReadAt reads data from memtable at offset

func (*MemFile) Size

func (m *MemFile) Size() int64

Size provides size of the memtable in bytes

func (*MemFile) Slice

func (m *MemFile) Slice(start int64, end int64) ([]byte, error)

Slice provide the data for start and end offset

func (*MemFile) Stat

func (m *MemFile) Stat() (os.FileInfo, error)

Stat provides DB state and size of memtable

func (*MemFile) Sync

func (m *MemFile) Sync() error

Sync flush the changes to memtable

func (*MemFile) Sys

func (m *MemFile) Sys() interface{}

Sys empty interface

func (*MemFile) Truncate

func (m *MemFile) Truncate(size int64) error

Truncate resize the memtable and shrink or extend the memtable

func (*MemFile) Type

func (m *MemFile) Type() string

Type indicate type of filesystem

func (*MemFile) WriteAt

func (m *MemFile) WriteAt(p []byte, off int64) (int, error)

WriteAt writes data to memtable at the given offset

Jump to

Keyboard shortcuts

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