This repository has been archived by the owner on Nov 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bindata.go
239 lines (214 loc) · 7.03 KB
/
bindata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Code generated by go-bindata.
// sources:
// data/designs/locks.json
// DO NOT EDIT!
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func binDataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("read %q: %v", name, err)
}
var buf bytes.Buffer
_, err = io.Copy(&buf, gz)
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("read %q: %v", name, err)
}
if clErr != nil {
return nil, err
}
return buf.Bytes(), nil
}
type asset struct {
bytes []byte
info os.FileInfo
}
type binDataFileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
}
func (fi binDataFileInfo) Name() string {
return fi.name
}
func (fi binDataFileInfo) Size() int64 {
return fi.size
}
func (fi binDataFileInfo) Mode() os.FileMode {
return fi.mode
}
func (fi binDataFileInfo) ModTime() time.Time {
return fi.modTime
}
func (fi binDataFileInfo) IsDir() bool {
return false
}
func (fi binDataFileInfo) Sys() interface{} {
return nil
}
var dataDesignsLocksJSONContent = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x94\x51\xc1\x4e\x83\x40\x10\xbd\xf7\x2b\x46\x0e\x05\x12\xc4\x78\xa5\xe1\xa4\x27\x63\xda\x43\x7b\x23\x8d\xd9\xb2\x53\xb2\x5a\x16\x0a\xbb\xad\x0d\xd9\x7f\x77\x66\xa9\xb5\x1e\x8c\x7a\x81\xd9\x79\xf3\xe6\xbd\x99\x19\x26\x00\xc1\x8b\x92\x41\x46\x3f\x89\xbd\xaa\xf4\xdd\xae\x29\xdf\xfa\x20\x61\x64\x27\x74\x65\x45\x85\x0c\xbf\x8a\x83\xe8\xcb\x4e\xb5\x66\xc4\x0e\x0a\x8f\x3d\x01\xdc\x82\x9e\x7b\x8b\x16\x2f\x4f\x4a\xd4\xa2\x65\xda\xd6\xea\xd2\xa8\x46\x47\xb2\x29\x63\x18\x40\x6d\x81\xc3\x74\x75\x6a\x11\xf2\x1c\x42\x96\x0b\x61\x3a\x85\xa8\x08\x7d\x93\x30\x19\x93\x28\xc3\x75\xaa\xb4\xc4\xf7\xc5\xd6\x53\x96\x46\x18\xdb\xc7\x70\x93\xc3\xed\x7d\xcc\xcd\xb0\x56\x26\x2a\x18\x7b\x26\x42\x02\x1c\x3d\x74\x28\x0c\xca\xb5\x7f\xc5\x33\x70\x2e\xf0\x96\x1c\x7d\x9d\x77\x6e\x5b\x49\x15\x57\xde\x4b\x4f\xb9\x76\xeb\x3d\x26\xd0\xe1\x9e\x65\x0e\xa2\x83\x0d\xe4\xf0\xb4\x5c\xcc\xd3\x56\x74\x3d\x46\x84\xa4\x9b\x46\x9e\x48\x80\x51\xaa\x26\x7c\xa0\x4d\x66\x4c\x4a\xad\x55\x32\x01\x9e\x31\x3b\x4f\x98\x00\x5b\xcc\x60\x53\x84\x1c\x84\xe4\x6f\x2e\x6a\xf4\x09\x0e\x38\x31\x0e\x48\x8c\xcf\x3d\x9c\x67\xc9\x20\xd2\x78\x84\x47\x8a\xa3\x38\xad\xd0\xac\x54\x4d\x51\xec\x66\x24\x66\x6c\xa7\xa1\xf0\x76\x4d\xc3\x0e\xa3\xa1\x21\x1d\xd3\x59\x4c\x80\xfd\xf0\x52\xc8\x98\x8b\xd7\xb4\x0c\x7f\x3b\xbe\x2c\x79\xf8\x79\xe0\xaf\x6d\x43\x7e\x39\xc6\x2f\x62\xdf\xfb\x5b\xfd\x1f\x85\xb1\xfa\xcf\x1a\x7c\xc9\x89\x9b\x7c\x04\x00\x00\xff\xff\xdf\x32\x77\xe0\xbd\x02\x00\x00")
func dataDesignsLocksJSONBytes() ([]byte, error) {
return binDataRead(
dataDesignsLocksJSONContent,
"data/designs/locks.json",
)
}
func dataDesignsLocksJSON() (*asset, error) {
locksBytes, err := dataDesignsLocksJSONBytes()
if err != nil {
return nil, err
}
info := binDataFileInfo{name: "data/designs/locks.json", size: 701, mode: os.FileMode(420), modTime: time.Unix(1437033599, 0)}
a := &asset{bytes: locksBytes, 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) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := binaryData[canonicalName]; 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)
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
}
// 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) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := binaryData[canonicalName]; 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(binaryData))
for name := range binaryData {
names = append(names, name)
}
return names
}
// binaryData is a table, holding each asset generator, mapped to its name.
var binaryData = map[string]func() (*asset, error){
"data/designs/locks.json": dataDesignsLocksJSON,
}
// 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 := binaryTree
if len(name) != 0 {
canonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(canonicalName, "/")
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 childName := range node.Children {
rv = append(rv, childName)
}
return rv, nil
}
type binTree struct {
Func func() (*asset, error)
Children map[string]*binTree
}
var binaryTree = &binTree{nil, map[string]*binTree{
"data": {nil, map[string]*binTree{
"designs": {nil, map[string]*binTree{
"locks.json": {dataDesignsLocksJSON, map[string]*binTree{}},
}},
}},
}}
// RestoreAsset restores 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, filepath.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
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
func filePath(dir, name string) string {
canonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
}