fs

package
v7.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilteredFS

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

FilteredFS is a wrapper around a fs.FS that filters out files that are not allowed to be read. This is used to prevent the interpreter from reading files, using protocols that are not allowed to be used by the interpreter on the blockchain. The whitelist and blacklist are mutually exclusive. If both are set, the blacklist will be ignored.

func NewFilteredFS

func NewFilteredFS(whitelist, blacklist []*url.URL, decorated fs.FS) *FilteredFS

NewFilteredFS returns a new FilteredFS object that will filter out files that are not allowed to be read according to the whitelist and blacklist parameters.

func (*FilteredFS) Open

func (f *FilteredFS) Open(name string) (fs.File, error)

Open opens the named file. The name parameter is a URL that will be parsed and checked against the whitelist and blacklist configured.

type Router

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

func NewRouter

func NewRouter() Router

func (*Router) Open

func (r *Router) Open(ctx context.Context, name string) (fs.File, error)

func (*Router) RegisterHandler

func (r *Router) RegisterHandler(handler URIHandler)

type URIHandler

type URIHandler interface {
	Scheme() string
	Open(ctx context.Context, uri *url.URL) (fs.File, error)
}

type VirtualFS

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

VirtualFS is the custom virtual file system used into the blockchain. It will hold a list of handler that can resolve file URI and return the corresponding binary file.

func NewVirtualFS

func NewVirtualFS(ctx goctx.Context, handlers []URIHandler) *VirtualFS

NewVirtualFS return a new VirtualFS object that will handle all virtual file on the interpreter. File can be provided from different sources like CosmWasm cw-storage smart contract.

func (*VirtualFS) Open

func (f *VirtualFS) Open(name string) (fs.File, error)

Open opens the named file.

When Open returns an error, it should be of type *PathError with the Op field set to "open", the Path field set to name, and the Err field describing the problem.

Open should reject attempts to open names that do not satisfy ValidPath(name), returning a *PathError with Err set to ErrInvalid or ErrNotExist.

type VirtualFile

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

func NewVirtualFile

func NewVirtualFile(src []byte, uri *url.URL, modTime time.Time) VirtualFile

func (VirtualFile) Close

func (o VirtualFile) Close() error

func (VirtualFile) Read

func (o VirtualFile) Read(b []byte) (int, error)

func (VirtualFile) Stat

func (o VirtualFile) Stat() (fs.FileInfo, error)

type VirtualFileInfo

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

func (VirtualFileInfo) IsDir

func (i VirtualFileInfo) IsDir() bool

func (VirtualFileInfo) ModTime

func (i VirtualFileInfo) ModTime() time.Time

func (VirtualFileInfo) Mode

func (i VirtualFileInfo) Mode() fs.FileMode

func (VirtualFileInfo) Name

func (i VirtualFileInfo) Name() string

func (VirtualFileInfo) Size

func (i VirtualFileInfo) Size() int64

func (VirtualFileInfo) Sys

func (i VirtualFileInfo) Sys() any

type WasmHandler

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

func NewWasmHandler

func NewWasmHandler(keeper types.WasmKeeper) WasmHandler

func (WasmHandler) Open

func (w WasmHandler) Open(ctx context.Context, uri *url.URL) (fs.File, error)

func (WasmHandler) Scheme

func (w WasmHandler) Scheme() string

Jump to

Keyboard shortcuts

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