fs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Package fs contains an HTTP file system that works with zip contents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile added in v0.2.0

func ReadFile(hfs http.FileSystem, name string) ([]byte, error)

ReadFile reads the contents of the file of hfs specified by name. Just as ioutil.ReadFile does.

func Register

func Register(data string)

Register registers zip contents data, later used to initialize the statik file system.

func Walk added in v0.2.0

func Walk(hfs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn.

As with filepath.Walk, if the walkFn returns filepath.SkipDir, then the directory is skipped.

Types

type StatikFS added in v0.2.0

type StatikFS struct {
	Files map[string]file
	Dirs  map[string][]string
}

StatikFS definition.

func New

func New() (*StatikFS, error)

New creates a new file system with the registered zip contents data. It unzips all files and stores them in an in-memory map.

func (*StatikFS) Open added in v0.2.0

func (fs *StatikFS) Open(name string) (http.File, error)

Open returns a file matching the given file name, or os.ErrNotExists if no file matching the given file name is found in the archive. If a directory is requested, Open returns the file named "index.html" in the requested directory, if that file exists.

func (*StatikFS) Readdir added in v0.3.0

func (fs *StatikFS) Readdir(folderPath string) ([]string, error)

Readdir method.

func (*StatikFS) Readfile added in v0.3.0

func (fs *StatikFS) Readfile(filePath string) ([]byte, error)

Readfile method.

Jump to

Keyboard shortcuts

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