fs

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fs implements a key-value store that stores keys as file names and values as file content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn added in v0.22.0

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

Conn is a connection to a directory on the filesystem.

It implements the kms.Conn interface and acts as KMS abstraction over a fileystem.

func NewConn added in v0.22.0

func NewConn(dir string) (*Conn, error)

NewConn returns a new Conn that reads from and writes to the given directory.

If the directory or any parent directory does not exist, NewConn creates them all.

It returns an error if dir exists but is not a directory.

func (*Conn) Create added in v0.22.0

func (c *Conn) Create(_ context.Context, name string, value []byte) error

Create creates a new file with the given name inside the Conn directory if and only if no such file exists.

It returns kes.ErrKeyExists if such a file already exists.

func (*Conn) Delete added in v0.22.0

func (c *Conn) Delete(_ context.Context, name string) error

Delete deletes the named file within the Conn directory if and only if it exists. It returns kes.ErrKeyNotFound if no such file exists.

func (*Conn) Get added in v0.22.0

func (c *Conn) Get(_ context.Context, name string) ([]byte, error)

Get reads the content of the named file within the Conn directory. It returns kes.ErrKeyNotFound if no such file exists.

func (*Conn) List added in v0.22.0

func (c *Conn) List(ctx context.Context) (kms.Iter, error)

List returns a Iter over the files within the Conn directory. The Iter must be closed to release any filesystem resources back to the OS.

func (*Conn) Status added in v0.22.0

func (c *Conn) Status(context.Context) (kms.State, error)

Status returns the current state of the Conn.

In particular, it reports whether the underlying filesystem is accessible.

type Iter added in v0.22.0

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

Iter is an iterator over all files within a directory. It must be closed to release any filesystem resources.

func NewIter added in v0.22.0

func NewIter(ctx context.Context, dir fs.ReadDirFile) *Iter

NewIter returns an Iter all files within the given directory. The Iter does not iterator recursively into subdirectories.

func (*Iter) Close added in v0.22.0

func (i *Iter) Close() error

Close closes the Iter and releases and filesystem resources back to the OS.

func (*Iter) Name added in v0.22.0

func (i *Iter) Name() string

Name returns the current name of the directory entry. It returns the empty string if there are no more entries or once the Iter has encountered an error.

func (*Iter) Next added in v0.22.0

func (i *Iter) Next() bool

Next reports whether there are more directory entries. It returns false when there are no more entries, the Iter got closed or once it encounters an error.

The name of the next directory entry is availbale via the Name method.

Jump to

Keyboard shortcuts

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