fileutil

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fileutil provides functionality to replace os and io calls with custom filesystems. It is a small wrapper around io/fs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// FS is the filesystem that Open, ReadFile and ReadDir will query.
	FS fs.FS = os.DirFS(".")
	// FixWindowsPaths will reset all file paths loaded to replace windows style slashes
	// with unix style slashes. This is important when using io/fs or embed, because the
	// path/filepath package will produce windows style paths on a windows system, but
	// these stdlib packages will reject all windows paths.
	FixWindowsPaths = true
	// OSFallback will fallback to loading via os.Open / io.ReadFile if loading otherwise fails.
	// This is necessary when reading system level fallback fonts. Fixed paths will not be applied
	// to this fallback route.
	OSFallback = true
)

Functions

func Open

func Open(file string) (io.ReadCloser, error)

Open is a wrapper around os.Open that will also check FS to access embedded data. The intended use is to use the an embedding library to create an Asset function that matches this signature.

func ReadDir

func ReadDir(file string) ([]fs.DirEntry, error)

ReadDir replaces ioutil.ReadDir, trying to use FS.

func ReadFile

func ReadFile(file string) ([]byte, error)

ReadFile replaces ioutil.ReadFile, trying to use FS.

Types

This section is empty.

Jump to

Keyboard shortcuts

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