filesystem

package
v0.195.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inject

func Inject(ctx context.Context, fs Service) context.Context

Inject will inject this filesystem Service into the context.

func ReadFile

func ReadFile(ctx context.Context, filename string) ([]byte, error)

ReadFile will open the file from the service and read the entire contents.

func Stat

func Stat(ctx context.Context, filename string) (os.FileInfo, error)

Stat will retrieve the os.FileInfo for a file.

Types

type Dependency

type Dependency struct {
	FS Service
}

Dependency will inject the filesystem Service into the dependency chain.

func (Dependency) Inject

func (d Dependency) Inject(ctx context.Context) context.Context

Inject will inject the filesystem Service into the dependency chain.

type File

type File interface {
	io.ReadCloser
	Stat() (os.FileInfo, error)
}

File is an interface for interacting with a file.

func OpenFile

func OpenFile(ctx context.Context, filename string) (File, error)

OpenFile will open the file from the service.

type Service

type Service interface {
	Open(fpath string) (File, error)
}

Service is the service for accessing the filesystem.

var SystemFS Service = systemFS{}

SystemFS implements the filesystem.Service by proxying all requests to the filesystem.

func Get

func Get(ctx context.Context) (Service, error)

Get will retrieve a filesystem Service from the context.Context.

Jump to

Keyboard shortcuts

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