directory

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMMapDirectory

func NewMMapDirectory(rootPath string) (*mmapDirectory, error)

func NewMemoryDirectory

func NewMemoryDirectory() *memoryDirectory

Types

type DataReader

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

func (*DataReader) Read

func (d *DataReader) Read(p []byte) (n int, err error)

type Directory

type Directory interface {
	OpenRead(path string) (*FileSlice, error)
	AtomicRead(path string) ([]byte, error)
	OpenWrite(path string) (WriteCloseSyncer, error)
	AtomicWrite(path string, data []byte) error
	Exists(path string) (bool, error)
}

type FileHandle

type FileHandle interface {
	io.ReaderAt
	Len() int
}

type FileSlice

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

func NewFileSlice

func NewFileSlice(data FileHandle, closer func() error) *FileSlice

func (*FileSlice) Close

func (f *FileSlice) Close() error

Close closes data file Close must be called only for the top level file slice, and must not for the child sliced one.

func (*FileSlice) Len

func (f *FileSlice) Len() int

func (*FileSlice) Read

func (f *FileSlice) Read(from, to int) ([]byte, error)

func (*FileSlice) Reader

func (f *FileSlice) Reader() *DataReader

func (*FileSlice) Slice

func (f *FileSlice) Slice(from, to int) *FileSlice

type ManagedDirectory

type ManagedDirectory struct {
	MetaInformation *MetaInformation
	// contains filtered or unexported fields
}

func NewManagedDirectory

func NewManagedDirectory(dir Directory) (*ManagedDirectory, error)

func (*ManagedDirectory) AtomicRead

func (m *ManagedDirectory) AtomicRead(path string) ([]byte, error)

func (*ManagedDirectory) AtomicWrite

func (m *ManagedDirectory) AtomicWrite(path string, data []byte) error

func (*ManagedDirectory) Exists

func (m *ManagedDirectory) Exists(path string) (bool, error)

func (*ManagedDirectory) OpenRead

func (m *ManagedDirectory) OpenRead(path string) (*FileSlice, error)

func (*ManagedDirectory) OpenWrite

func (m *ManagedDirectory) OpenWrite(path string) (WriteCloseSyncer, error)

type MetaInformation

type MetaInformation struct {
	sync.RWMutex
	ManagedPaths []string
}

func (*MetaInformation) AddPath

func (m *MetaInformation) AddPath(path string) (added bool)

func (*MetaInformation) RemovePath

func (m *MetaInformation) RemovePath(path string)

type WriteCloseSyncer

type WriteCloseSyncer interface {
	io.WriteCloser
	Sync() error
}

Jump to

Keyboard shortcuts

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