v0.0.0-...-8dcdab8 Latest Latest

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 4 Imported by: 0




This section is empty.


This section is empty.


func Info

func Info(f File) os.FileInfo

Info produces an implementation of os.FileInfo from a an implementation of File.

func LazyReadCloser

func LazyReadCloser(openFunc func() (io.Reader, error),
	closeFunc func() error) io.ReadCloser

LazyReadCloser is an implementation of io.ReadCloser that defers its own initialization until the first attempted read.


type CustomFileArgs

type CustomFileArgs struct {
	Name       string
	Size       int
	ModTime    time.Time
	IsDir      bool
	ReadCloser io.ReadCloser

CustomFileArgs takes all elements that need to be provided to the CustomFile function.

type File

type File interface {

	// Name returns the base name of the file, not a
	// full path (see filepath.Base).
	Name() string

	// Size returns the size of the file in bytes. If
	// the file represents a directory the size returned
	// should be zero.
	Size() int

	// ModTime returns the time the file was most
	// recently modified.
	ModTime() time.Time

	// Read implements io.Reader to retrieve file
	// contents.
	Read(p []byte) (n int, err error)

	// Close implements io.Closer.
	Close() error

	// IsDir returns true if the File represents a
	// directory.
	IsDir() bool

File represents a file from the filesystem.

func CustomFile

func CustomFile(args CustomFileArgs) File

CustomFile makes it possible to construct a custom file that implements the File interface without necessarily being backed by an actual file on the filesystem.

func LazyOpen

func LazyOpen(path string) (File, error)

LazyOpen is an alternative implementation of Open that defers actually opening the file until the first attempted read.

func Open

func Open(path string) (File, error)

Open mimics the os.Open function but returns an implementation of File.

Jump to

Keyboard shortcuts

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