fs

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ZipData string

Functions

func ReadFile added in v0.1.7

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 statical file system.

func Unzip added in v0.1.9

func Unzip(zf *zip.File) ([]byte, error)

func Walk added in v0.1.7

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 DirInfo added in v0.1.9

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

func (DirInfo) IsDir added in v0.1.9

func (di DirInfo) IsDir() bool

func (DirInfo) ModTime added in v0.1.9

func (di DirInfo) ModTime() time.Time

func (DirInfo) Mode added in v0.1.9

func (di DirInfo) Mode() os.FileMode

func (DirInfo) Name added in v0.1.9

func (di DirInfo) Name() string

func (DirInfo) RawName added in v0.1.9

func (di DirInfo) RawName() string

func (DirInfo) Size added in v0.1.9

func (di DirInfo) Size() int64

func (DirInfo) Sys added in v0.1.9

func (di DirInfo) Sys() interface{}

type File added in v0.1.7

type File struct {
	os.FileInfo
	Data []byte
	Fs   *StaticalFS
}

file holds unzipped read-only file contents and file metadata.

type HttpFile added in v0.1.9

type HttpFile struct {
	File
	// contains filtered or unexported fields
}

HttpFile represents an HTTP file and acts as a bridge between file and http.File.

func NewHTTPFile added in v0.1.9

func NewHTTPFile(file File) *HttpFile

func (*HttpFile) Close added in v0.1.9

func (f *HttpFile) Close() error

func (*HttpFile) IsDir added in v0.1.9

func (f *HttpFile) IsDir() bool

func (*HttpFile) Read added in v0.1.9

func (f *HttpFile) Read(p []byte) (n int, err error)

Read reads bytes into p, returns the number of read bytes.

func (*HttpFile) Readdir added in v0.1.9

func (f *HttpFile) Readdir(count int) ([]os.FileInfo, error)

Readdir returns an empty slice of files, directory listing is disabled.

func (*HttpFile) Seek added in v0.1.9

func (f *HttpFile) Seek(offset int64, whence int) (ret int64, err error)

Seek seeks to the offset.

func (*HttpFile) Stat added in v0.1.9

func (f *HttpFile) Stat() (os.FileInfo, error)

type StaticalFS added in v0.1.8

type StaticalFS struct {
	Files map[string]File
	Dirs  map[string][]string
}

func New

func New() (*StaticalFS, 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 (*StaticalFS) Open added in v0.1.8

func (fs *StaticalFS) 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.

Jump to

Keyboard shortcuts

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