fs

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fs contains a filesystem-based Impl.

Index

Constants

View Source
const (
	// DirPerm is default directory permissions.
	DirPerm = 0o755

	// FilePerm is default file permissions.
	FilePerm = 0o644
)

Variables

View Source
var OpenFile = func(name string, flag int, perm os.FileMode) (io.ReadWriteCloser, error) {
	return os.OpenFile(name, flag, perm)
}

OpenFile is the func used to open files. Only exported to allow testing racy filesystem errors.

Functions

func Proto added in v0.5.0

func Proto(o opts.Opts) (impl.Impl, error)

Proto is the Proto for FS.

Types

type FS

type FS struct {
	Base string
	Ext  string

	DirPerm  os.FileMode
	FilePerm os.FileMode
}

FS is a filesystem-based Impl.

func (*FS) Close

func (f *FS) Close() error

Close doesn't do anything for now. Might keep a basedir handle or something in future.

func (*FS) Del

func (f *FS) Del(k string) error

Del removes the file that corresponds to the given key.

func (*FS) Get

func (f *FS) Get(k string) ([]byte, error)

Get opens and reads the file specified by the key.

func (*FS) Keys

func (f *FS) Keys() ([]string, error)

Keys returns a list of keys, based on the list of files in Base. Files are filtered by, and stripped of, the extension Ext.

func (*FS) Set

func (f *FS) Set(key string, data []byte) error

Set writes the given data to the file which corresponds to the given key.

Jump to

Keyboard shortcuts

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