mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
194 lines
10 KiB
Go
194 lines
10 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 _text_png = []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\xc0\x00\x00\x00\x80\b\x03\x00\x00\x00jZ\x96Y\x00\x00\x00\x06PLTE\x00\x00\x00\xff\xff\xff\xa5ٟ\xdd\x00\x00\x00\x01tRNS\x00@\xe6\xd8f\x00\x00\a\xb2IDATx\x9c\xec\x1c\x89v#!\b\xf2\xe6\xff\u007f\x99MT\xe4\xf4\x984m\x8e\r\xbb\xb5\x13\x83\x1c\xe2\x01\x8c\xf6\x02o\x0e_\x05n\x80\x83\x9aX?j\x1b\xf1w\xda\xde\xe0\x02x\x05iu\xfd\x87\xf5\xa1Է\xb2}\x8b\x86<\xb6\xf2\xb9`,\x80t\xfb\xd7>\xd0\x15J)ߒ\xd5\xe0/`\xd0Gҗ\x87\xae.\xf2\xa3\xb2g\x11\x9e|c\xaa\xa8\xfb\x12D\x1a\xbb\x90\xf0\xba}\xb8\xfep\xdda\xe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x98qю\xb7EjE\x16\x0fd\xb4w\xe3\x01h\xa9\xdb\xedx`\xc1\x05!*0\x85\x9f&\x83«\x8b\x19\xee\x83\xf1\x1e\x05\xdb\xfcp\xb3\x81\xfe\xfeX;B\xe9\x1f\x8f\xcaʚ\xf9\x8b%\x80\xb9Q0\xf6g\xa9I\xe7\xef\x15\xf8\x12L\x00\xd45\x9a\x95\x12V\x8e\xcaqK\x80ɍ\x02]r\xca\x16\x97\x98\xaa<6\xa4W3\x99Ƙs\xd8\xf0\xba$\xfc<3Əԅt\xa5\xf1\xd3\xef\x8d\a6\xe0\x1eg\xfd\xe4%\xa0i\x02\xe01\xc0\xa4RK\xfbk\x02<\x94r\xff\xbe\x97\x9b\x93x\x9dqXLb\x11\x0e\xb0\xfd\x815_\x02\x9c\xbd\xb3n:\xe7dg\xde\x03s\x1ez\xd7\xc3%\xf69\xda\u007f\x03\xa8\xff\xbc\xdeG\xdcP\xfe\x17\x00\x00\xff\xff!o0\xc6\x16:4\xa9\x00\x00\x00\x00IEND\xaeB`\x82")
|
||
|
||
func text_png_bytes() ([]byte, error) {
|
||
return _text_png, nil
|
||
}
|
||
|
||
func text_png() (*asset, error) {
|
||
bytes, err := text_png_bytes()
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
info := bindata_file_info{name: "text.png", size: 2058, mode: os.FileMode(420), modTime: time.Unix(1420820510, 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){
|
||
"text.png": text_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{
|
||
"text.png": &_bintree_t{text_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, "/")...)...)
|
||
}
|