mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-28 12:48:54 +01:00
194 lines
7.2 KiB
Go
194 lines
7.2 KiB
Go
|
package assets
|
|||
|
|
|||
|
import (
|
|||
|
"fmt"
|
|||
|
"io/ioutil"
|
|||
|
"os"
|
|||
|
"path"
|
|||
|
"path/filepath"
|
|||
|
"strings"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
type asset struct {
|
|||
|
bytes []byte
|
|||
|
info os.FileInfo
|
|||
|
}
|
|||
|
|
|||
|
type bindata_file_info struct {
|
|||
|
name string
|
|||
|
size int64
|
|||
|
mode os.FileMode
|
|||
|
modTime time.Time
|
|||
|
}
|
|||
|
|
|||
|
func (fi bindata_file_info) Name() string {
|
|||
|
return fi.name
|
|||
|
}
|
|||
|
func (fi bindata_file_info) Size() int64 {
|
|||
|
return fi.size
|
|||
|
}
|
|||
|
func (fi bindata_file_info) Mode() os.FileMode {
|
|||
|
return fi.mode
|
|||
|
}
|
|||
|
func (fi bindata_file_info) ModTime() time.Time {
|
|||
|
return fi.modTime
|
|||
|
}
|
|||
|
func (fi bindata_file_info) IsDir() bool {
|
|||
|
return false
|
|||
|
}
|
|||
|
func (fi bindata_file_info) Sys() interface{} {
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
var _arcadefont_png = []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x80\x00\x00\x000\b\x03\x00\x00\x00\xee*\x82\x8c\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5ٟ\xdd\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\x03\x98IDATx\x9c\xc4X\x89\x96\xac(\f\xe5\xd6\xf3\xff\u007f9\xd3B\x96\x9b\x18ѩ\xe99/ݥ\x82\x81\xec\v~F\x00\xa0\xd7\xf5\x10\xf3t=\xdf#\xe1\xdbCY\xf4\x0e0>\xbb\x97F\xf9\xdc{\x8e\xe6\xbf\b*\xa2\xfc\\%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8\xff'\x00\x00\xff\xff\"\xd9\xedҰ\xcb\xea\x95\x00\x00\x00\x00IEND\xaeB`\x82")
|
|||
|
|
|||
|
func arcadefont_png_bytes() ([]byte, error) {
|
|||
|
return _arcadefont_png, nil
|
|||
|
}
|
|||
|
|
|||
|
func arcadefont_png() (*asset, error) {
|
|||
|
bytes, err := arcadefont_png_bytes()
|
|||
|
if err != nil {
|
|||
|
return nil, err
|
|||
|
}
|
|||
|
|
|||
|
info := bindata_file_info{name: "arcadefont.png", size: 1008, mode: os.FileMode(420), modTime: time.Unix(1463226773, 0)}
|
|||
|
a := &asset{bytes: bytes, info: info}
|
|||
|
return a, nil
|
|||
|
}
|
|||
|
|
|||
|
// Asset loads and returns the asset for the given name.
|
|||
|
// It returns an error if the asset could not be found or
|
|||
|
// could not be loaded.
|
|||
|
func Asset(name string) ([]byte, error) {
|
|||
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
|||
|
if f, ok := _bindata[cannonicalName]; ok {
|
|||
|
a, err := f()
|
|||
|
if err != nil {
|
|||
|
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
|
|||
|
}
|
|||
|
return a.bytes, nil
|
|||
|
}
|
|||
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|||
|
}
|
|||
|
|
|||
|
// AssetInfo loads and returns the asset info for the given name.
|
|||
|
// It returns an error if the asset could not be found or
|
|||
|
// could not be loaded.
|
|||
|
func AssetInfo(name string) (os.FileInfo, error) {
|
|||
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
|||
|
if f, ok := _bindata[cannonicalName]; ok {
|
|||
|
a, err := f()
|
|||
|
if err != nil {
|
|||
|
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
|
|||
|
}
|
|||
|
return a.info, nil
|
|||
|
}
|
|||
|
return nil, fmt.Errorf("AssetInfo %s not found", name)
|
|||
|
}
|
|||
|
|
|||
|
// AssetNames returns the names of the assets.
|
|||
|
func AssetNames() []string {
|
|||
|
names := make([]string, 0, len(_bindata))
|
|||
|
for name := range _bindata {
|
|||
|
names = append(names, name)
|
|||
|
}
|
|||
|
return names
|
|||
|
}
|
|||
|
|
|||
|
// _bindata is a table, holding each asset generator, mapped to its name.
|
|||
|
var _bindata = map[string]func() (*asset, error){
|
|||
|
"arcadefont.png": arcadefont_png,
|
|||
|
}
|
|||
|
|
|||
|
// AssetDir returns the file names below a certain
|
|||
|
// directory embedded in the file by go-bindata.
|
|||
|
// For example if you run go-bindata on data/... and data contains the
|
|||
|
// following hierarchy:
|
|||
|
// data/
|
|||
|
// foo.txt
|
|||
|
// img/
|
|||
|
// a.png
|
|||
|
// b.png
|
|||
|
// then AssetDir("data") would return []string{"foo.txt", "img"}
|
|||
|
// AssetDir("data/img") would return []string{"a.png", "b.png"}
|
|||
|
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
|
|||
|
// AssetDir("") will return []string{"data"}.
|
|||
|
func AssetDir(name string) ([]string, error) {
|
|||
|
node := _bintree
|
|||
|
if len(name) != 0 {
|
|||
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
|||
|
pathList := strings.Split(cannonicalName, "/")
|
|||
|
for _, p := range pathList {
|
|||
|
node = node.Children[p]
|
|||
|
if node == nil {
|
|||
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if node.Func != nil {
|
|||
|
return nil, fmt.Errorf("Asset %s not found", name)
|
|||
|
}
|
|||
|
rv := make([]string, 0, len(node.Children))
|
|||
|
for name := range node.Children {
|
|||
|
rv = append(rv, name)
|
|||
|
}
|
|||
|
return rv, nil
|
|||
|
}
|
|||
|
|
|||
|
type _bintree_t struct {
|
|||
|
Func func() (*asset, error)
|
|||
|
Children map[string]*_bintree_t
|
|||
|
}
|
|||
|
|
|||
|
var _bintree = &_bintree_t{nil, map[string]*_bintree_t{
|
|||
|
"arcadefont.png": {arcadefont_png, map[string]*_bintree_t{}},
|
|||
|
}}
|
|||
|
|
|||
|
// Restore an asset under the given directory
|
|||
|
func RestoreAsset(dir, name string) error {
|
|||
|
data, err := Asset(name)
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
info, err := AssetInfo(name)
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
err = os.MkdirAll(_filePath(dir, path.Dir(name)), os.FileMode(0755))
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
// Restore assets under the given directory recursively
|
|||
|
func RestoreAssets(dir, name string) error {
|
|||
|
children, err := AssetDir(name)
|
|||
|
if err != nil { // File
|
|||
|
return RestoreAsset(dir, name)
|
|||
|
} else { // Dir
|
|||
|
for _, child := range children {
|
|||
|
err = RestoreAssets(dir, path.Join(name, child))
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return nil
|
|||
|
}
|
|||
|
|
|||
|
func _filePath(dir, name string) string {
|
|||
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
|||
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
|||
|
}
|