assetdb

package
v2.0.0-alpha.32 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

+build !desktop

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetDB

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

AssetDB is a database for assets encoded as byte slices

func NewAssetDB

func NewAssetDB() *AssetDB

NewAssetDB creates a new AssetDB and initialises a blank db

func (*AssetDB) AddAsset

func (a *AssetDB) AddAsset(name string, data []byte)

AddAsset saves the given byte slice under the given name

func (*AssetDB) Dump

func (a *AssetDB) Dump()

func (*AssetDB) Open

func (a *AssetDB) Open(name string) (http.File, error)

Open implements the http.FileSystem interface for the AssetDB

func (*AssetDB) Read

func (a *AssetDB) Read(name string) ([]byte, error)

Asset retrieves the byte slice for the given name

func (*AssetDB) Remove

func (a *AssetDB) Remove(name string)

Remove removes the named asset

func (*AssetDB) Serialize

func (a *AssetDB) Serialize(name, pkg string) string

Serialize converts the entire database to a file that when compiled will reconstruct the AssetDB during init() name: name of the asset.AssetDB instance pkg: package name placed at the top of the file

func (*AssetDB) String

func (a *AssetDB) String(name string) (string, error)

AssetAsString returns the asset as a string. It also returns a boolean indicating whether the asset existed or not.

type Entry

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

Entry implements the http.File interface to allow for use in the http.FileSystem implementation of AssetDB

func (Entry) Close

func (e Entry) Close() error

Close is a noop

func (*Entry) Read

func (e *Entry) Read(p []byte) (n int, err error)

Read fills the slice provided returning how many bytes were written and any errors encountered

func (Entry) Readdir

func (e Entry) Readdir(count int) ([]os.FileInfo, error)

Readdir returns the directory entries inside this entry if it is a directory

func (*Entry) Seek

func (e *Entry) Seek(offset int64, whence int) (int64, error)

Seek seeks to the specified offset from the location specified by whence

func (Entry) Stat

func (e Entry) Stat() (os.FileInfo, error)

Stat returns information about this directory entry

type FI

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

FI is the AssetDB implementation of os.FileInfo.

func (FI) IsDir

func (fi FI) IsDir() bool

IsDir returns true if this is a directory

func (FI) ModTime

func (fi FI) ModTime() time.Time

ModTime always returns now

func (FI) Mode

func (fi FI) Mode() os.FileMode

Mode returns the file as readonly and directories as world writeable and executable

func (FI) Name

func (fi FI) Name() string

Name returns the name of this object without any leading slashes

func (FI) Size

func (fi FI) Size() int64

Size returns the size of this item

func (FI) Sys

func (fi FI) Sys() interface{}

Sys returns nil

Jump to

Keyboard shortcuts

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