ifs

package
v4.0.0-...-2c57b5f Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileWrite

func FileWrite(file fs.File, data []byte) (int, error)

FileWrite attempts to write to an fs.File provided it supports io.Writer.

func IsOS

func IsOS(f FS) bool

IsOS returns true if the provided FS implementation is a wrapper around OS access obtained via OS().

func ReadFile

func ReadFile(f fs.FS, name string) ([]byte, error)

ReadFile opens a file with the RDONLY flag and returns all bytes from it.

func ToHTTP

func ToHTTP(f fs.FS) *asHTTP

ToHTTP converts an fs.FS into an http.FileSystem in a way that doesn't modify the root path.

func WriteFile

func WriteFile(f fs.FS, name string, data []byte, perm fs.FileMode) error

WriteFile opens a file with O_WRONLY|O_CREATE|O_TRUNC flags and writes the data to it.

Types

type FS

type FS interface {
	Open(name string) (fs.File, error)
	OpenFile(name string, flag int, perm fs.FileMode) (fs.File, error)
	Stat(name string) (fs.FileInfo, error)
	Remove(name string) error
	MkdirAll(path string, perm fs.FileMode) error
}

FS is a superset of fs.FS that includes goodies that bento components specifically need.

func OS

func OS() FS

OS implements fs.FS as if calls were being made directly via the os package, with which relative paths are resolved from the directory the process is executed from.

Jump to

Keyboard shortcuts

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