fs

package
v0.0.0-...-1de2f69 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(fs Filesys)

Debug prints out all the files in a Filesys, along with their sizes.

func DeleteAll

func DeleteAll(fs Filesys)

DeleteAll deletes all files within a Filesys (which is a single directory).

Types

type File

type File interface {
	io.WriteCloser
	Sync()
}

File is a writeable file.

type Filesys

type Filesys interface {
	Open(fname string) ReadFile
	List() []string

	Create(fname string) File
	Delete(fname string)
	Truncate(fname string)
	Rename(src, dst string)
	AtomicCreateWith(fname string, data []byte)

	// performance counters
	GetStats() Stats
}

Filesys is a database-specific API for accessing the file system.

Note that an instance of this interface only exposes a single directory (there are no directory names in these methods).

Callers are expected to follow some rules when calling this API:

Open:      fname should exist
Create:    fname should not exist
Delete:    fname should exist
Truncate:  fname should exist

func DirFs

func DirFs(basedir string) Filesys

DirFs creates a Filesys backed by the OS, using basedir.

Creates basedir if it does not exist.

func FromAfero

func FromAfero(fs afero.Fs) Filesys

FromAfero creates an fs.Filesys from any Afero file system.

This implementation will use absolute filenames for the database files; use an afero.BasePathFs to make sure all database files are created within a particular directory.

Deletes all files named *.tmp, as a file-system recovery for AtomicCreateWith.

func MemFs

func MemFs() Filesys

MemFs creates an in-memory Filesys

type ReadFile

type ReadFile interface {
	Size() int
	ReadAt(offset int, length int) []byte
	io.ReadCloser
}

ReadFile is a read-only file.

type Stats

type Stats struct {
	ReadOps    int
	ReadBytes  int
	WriteOps   int
	WriteBytes int
}

Stats holds some basic stats about what filesystem operations have been issued.

Jump to

Keyboard shortcuts

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