|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "bytes" |
| 5 | + "compress/gzip" |
| 6 | + "fmt" |
| 7 | + "io" |
| 8 | + "strings" |
| 9 | + "os" |
| 10 | + "time" |
| 11 | + "io/ioutil" |
| 12 | + "path" |
| 13 | + "path/filepath" |
| 14 | +) |
| 15 | + |
| 16 | +func bindata_read(data []byte, name string) ([]byte, error) { |
| 17 | + gz, err := gzip.NewReader(bytes.NewBuffer(data)) |
| 18 | + if err != nil { |
| 19 | + return nil, fmt.Errorf("Read %q: %v", name, err) |
| 20 | + } |
| 21 | + |
| 22 | + var buf bytes.Buffer |
| 23 | + _, err = io.Copy(&buf, gz) |
| 24 | + gz.Close() |
| 25 | + |
| 26 | + if err != nil { |
| 27 | + return nil, fmt.Errorf("Read %q: %v", name, err) |
| 28 | + } |
| 29 | + |
| 30 | + return buf.Bytes(), nil |
| 31 | +} |
| 32 | + |
| 33 | +type asset struct { |
| 34 | + bytes []byte |
| 35 | + info os.FileInfo |
| 36 | +} |
| 37 | + |
| 38 | +type bindata_file_info struct { |
| 39 | + name string |
| 40 | + size int64 |
| 41 | + mode os.FileMode |
| 42 | + modTime time.Time |
| 43 | +} |
| 44 | + |
| 45 | +func (fi bindata_file_info) Name() string { |
| 46 | + return fi.name |
| 47 | +} |
| 48 | +func (fi bindata_file_info) Size() int64 { |
| 49 | + return fi.size |
| 50 | +} |
| 51 | +func (fi bindata_file_info) Mode() os.FileMode { |
| 52 | + return fi.mode |
| 53 | +} |
| 54 | +func (fi bindata_file_info) ModTime() time.Time { |
| 55 | + return fi.modTime |
| 56 | +} |
| 57 | +func (fi bindata_file_info) IsDir() bool { |
| 58 | + return false |
| 59 | +} |
| 60 | +func (fi bindata_file_info) Sys() interface{} { |
| 61 | + return nil |
| 62 | +} |
| 63 | + |
| 64 | +var _include_basht_bash = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x74\x53\xd1\x6f\x9b\x3e\x10\x7e\xc6\x7f\xc5\xfd\x90\x55\x88\x2a\x7e\x4a\xb6\xb7\x54\x68\xe9\xba\x54\xab\xd4\x25\x53\x68\x9f\xa2\x08\x21\x62\x1a\x34\x0a\x91\x6d\xb6\x49\x19\xff\xfb\xee\x6c\x87\x42\xb6\xe5\x01\xc7\xe7\xef\xbe\xef\xee\x3b\x9b\xa5\x69\xde\xd4\x3a\x2b\x6b\x15\x4e\xe0\xc4\xbc\xaa\xc9\xb3\x0a\xc4\x0d\x14\x8d\x04\x01\x65\x0d\x3e\x3f\x2d\xe6\xef\x3a\xff\x06\xf6\x0d\x6c\xb7\xb8\x17\x3e\xc4\x31\xae\x33\x1f\x76\x3b\xb8\xba\x02\x29\x74\x2b\x6b\x98\x12\xa4\xc6\x5c\xb7\x9f\xb1\x8e\xa1\x40\x91\x95\xd5\x97\x2c\x97\xcd\x50\xa1\x2a\x6b\x11\x13\xc5\x0d\xa8\x43\x59\x68\xe6\xa5\xa9\x16\x4a\xa7\x4a\x67\xba\x55\xf1\xac\x0f\xbc\x0a\xa5\xb2\x17\x02\x53\xce\x1c\xf8\xc2\x47\xde\x27\x43\x1b\x07\xe2\x3b\x92\x0d\x34\x80\x7f\xbc\x4d\x3e\xa7\xc9\xfa\x79\x73\xb7\x9c\xf3\xc7\x87\xd5\x72\xb5\x0e\x18\x7b\xc5\x16\x87\xfa\xb2\xad\x81\x92\xc4\x1e\x50\x51\x6a\xfc\x36\x47\xd8\xb7\x32\xd3\x65\x53\x33\x6f\x2f\xf2\x2a\x93\x02\xa2\x0c\x8e\xb2\xc9\xb1\x06\xb1\x67\x1e\x66\xc5\x53\xe6\xd9\x44\xf3\x0f\x5d\x2a\x70\x43\x46\xf1\x05\xf5\xcf\x3c\x4f\x35\xad\xcc\x05\x1a\x44\x27\x3e\x06\x08\xa5\x0d\x24\xec\x79\xef\xe1\x17\xbc\x48\x71\x84\xa0\x0f\x15\xf0\x94\x06\x18\xce\x7e\x7c\x83\xe0\x74\x94\x65\xad\x81\xbf\xef\x82\x89\xe3\xf5\xca\x02\xfe\x83\xb7\x89\xa1\x82\xf6\x69\x3e\x7d\x85\xdb\xc5\x8e\x06\xa5\x0f\xa2\x26\xbc\xd7\xd6\x4a\x68\x18\x39\x0b\x63\x5b\x0d\x4c\xe4\x87\x06\xfc\x18\x87\xba\x79\x5e\x01\x92\x9a\xa8\xf1\x05\x6d\x4f\x96\x77\xeb\xd5\xa7\xc4\x06\xb9\x36\xcb\x78\x58\xfc\x34\xda\xcf\x23\xfe\xa1\x73\x14\xcd\xf1\x92\xe1\xec\x71\xcc\xc3\x90\x13\x20\xe2\x46\x69\x32\x31\xc7\x7d\x2f\xd7\x71\x48\xfd\xd9\x28\x19\x4f\x78\x5c\xaf\x67\x0e\x89\x6e\x98\xeb\x38\xd2\x36\x57\x73\x8a\xf7\x72\xe0\x82\xeb\x2f\x8a\x22\xf8\x7a\x9b\x24\xd8\x20\x84\xfc\x74\xae\xa3\x53\x13\x5b\x98\xa8\x94\xb5\xe3\x3c\x5f\x12\xb4\x7f\x7b\xcd\x01\xd5\xfd\xed\xc3\xe3\xbf\xa8\x2e\x6b\x73\x66\xfb\x17\x75\x39\x36\xc0\xdf\x25\x72\x00\x70\x35\x95\xec\x6d\x31\x5f\x7a\x6b\xcc\x7d\x2d\xee\xac\x6a\x8b\xb6\xaf\x74\x3a\x12\xb5\x82\x9b\x0c\xaf\x22\xbd\x00\x92\x54\xff\xfb\xac\x17\xb2\xe7\xe4\x12\x06\x9d\x21\x7f\xcd\x01\x27\xe2\x1e\xd1\x9f\x1c\x64\x8f\x09\xfe\x2c\xf5\x19\xcc\xa8\xf0\x8e\xfd\x0e\x00\x00\xff\xff\xb6\xec\xc7\x36\x75\x04\x00\x00") |
| 65 | + |
| 66 | +func include_basht_bash_bytes() ([]byte, error) { |
| 67 | + return bindata_read( |
| 68 | + _include_basht_bash, |
| 69 | + "include/basht.bash", |
| 70 | + ) |
| 71 | +} |
| 72 | + |
| 73 | +func include_basht_bash() (*asset, error) { |
| 74 | + bytes, err := include_basht_bash_bytes() |
| 75 | + if err != nil { |
| 76 | + return nil, err |
| 77 | + } |
| 78 | + |
| 79 | + info := bindata_file_info{name: "include/basht.bash", size: 1141, mode: os.FileMode(420), modTime: time.Unix(1426344369, 0)} |
| 80 | + a := &asset{bytes: bytes, info: info} |
| 81 | + return a, nil |
| 82 | +} |
| 83 | + |
| 84 | +// Asset loads and returns the asset for the given name. |
| 85 | +// It returns an error if the asset could not be found or |
| 86 | +// could not be loaded. |
| 87 | +func Asset(name string) ([]byte, error) { |
| 88 | + cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 89 | + if f, ok := _bindata[cannonicalName]; ok { |
| 90 | + a, err := f() |
| 91 | + if err != nil { |
| 92 | + return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err) |
| 93 | + } |
| 94 | + return a.bytes, nil |
| 95 | + } |
| 96 | + return nil, fmt.Errorf("Asset %s not found", name) |
| 97 | +} |
| 98 | + |
| 99 | +// MustAsset is like Asset but panics when Asset would return an error. |
| 100 | +// It simplifies safe initialization of global variables. |
| 101 | +func MustAsset(name string) []byte { |
| 102 | + a, err := Asset(name) |
| 103 | + if (err != nil) { |
| 104 | + panic("asset: Asset(" + name + "): " + err.Error()) |
| 105 | + } |
| 106 | + |
| 107 | + return a |
| 108 | +} |
| 109 | + |
| 110 | +// AssetInfo loads and returns the asset info for the given name. |
| 111 | +// It returns an error if the asset could not be found or |
| 112 | +// could not be loaded. |
| 113 | +func AssetInfo(name string) (os.FileInfo, error) { |
| 114 | + cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 115 | + if f, ok := _bindata[cannonicalName]; ok { |
| 116 | + a, err := f() |
| 117 | + if err != nil { |
| 118 | + return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err) |
| 119 | + } |
| 120 | + return a.info, nil |
| 121 | + } |
| 122 | + return nil, fmt.Errorf("AssetInfo %s not found", name) |
| 123 | +} |
| 124 | + |
| 125 | +// AssetNames returns the names of the assets. |
| 126 | +func AssetNames() []string { |
| 127 | + names := make([]string, 0, len(_bindata)) |
| 128 | + for name := range _bindata { |
| 129 | + names = append(names, name) |
| 130 | + } |
| 131 | + return names |
| 132 | +} |
| 133 | + |
| 134 | +// _bindata is a table, holding each asset generator, mapped to its name. |
| 135 | +var _bindata = map[string]func() (*asset, error){ |
| 136 | + "include/basht.bash": include_basht_bash, |
| 137 | +} |
| 138 | + |
| 139 | +// AssetDir returns the file names below a certain |
| 140 | +// directory embedded in the file by go-bindata. |
| 141 | +// For example if you run go-bindata on data/... and data contains the |
| 142 | +// following hierarchy: |
| 143 | +// data/ |
| 144 | +// foo.txt |
| 145 | +// img/ |
| 146 | +// a.png |
| 147 | +// b.png |
| 148 | +// then AssetDir("data") would return []string{"foo.txt", "img"} |
| 149 | +// AssetDir("data/img") would return []string{"a.png", "b.png"} |
| 150 | +// AssetDir("foo.txt") and AssetDir("notexist") would return an error |
| 151 | +// AssetDir("") will return []string{"data"}. |
| 152 | +func AssetDir(name string) ([]string, error) { |
| 153 | + node := _bintree |
| 154 | + if len(name) != 0 { |
| 155 | + cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 156 | + pathList := strings.Split(cannonicalName, "/") |
| 157 | + for _, p := range pathList { |
| 158 | + node = node.Children[p] |
| 159 | + if node == nil { |
| 160 | + return nil, fmt.Errorf("Asset %s not found", name) |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | + if node.Func != nil { |
| 165 | + return nil, fmt.Errorf("Asset %s not found", name) |
| 166 | + } |
| 167 | + rv := make([]string, 0, len(node.Children)) |
| 168 | + for name := range node.Children { |
| 169 | + rv = append(rv, name) |
| 170 | + } |
| 171 | + return rv, nil |
| 172 | +} |
| 173 | + |
| 174 | +type _bintree_t struct { |
| 175 | + Func func() (*asset, error) |
| 176 | + Children map[string]*_bintree_t |
| 177 | +} |
| 178 | +var _bintree = &_bintree_t{nil, map[string]*_bintree_t{ |
| 179 | + "include": &_bintree_t{nil, map[string]*_bintree_t{ |
| 180 | + "basht.bash": &_bintree_t{include_basht_bash, map[string]*_bintree_t{ |
| 181 | + }}, |
| 182 | + }}, |
| 183 | +}} |
| 184 | + |
| 185 | +// Restore an asset under the given directory |
| 186 | +func RestoreAsset(dir, name string) error { |
| 187 | + data, err := Asset(name) |
| 188 | + if err != nil { |
| 189 | + return err |
| 190 | + } |
| 191 | + info, err := AssetInfo(name) |
| 192 | + if err != nil { |
| 193 | + return err |
| 194 | + } |
| 195 | + err = os.MkdirAll(_filePath(dir, path.Dir(name)), os.FileMode(0755)) |
| 196 | + if err != nil { |
| 197 | + return err |
| 198 | + } |
| 199 | + err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode()) |
| 200 | + if err != nil { |
| 201 | + return err |
| 202 | + } |
| 203 | + err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) |
| 204 | + if err != nil { |
| 205 | + return err |
| 206 | + } |
| 207 | + return nil |
| 208 | +} |
| 209 | + |
| 210 | +// Restore assets under the given directory recursively |
| 211 | +func RestoreAssets(dir, name string) error { |
| 212 | + children, err := AssetDir(name) |
| 213 | + if err != nil { // File |
| 214 | + return RestoreAsset(dir, name) |
| 215 | + } else { // Dir |
| 216 | + for _, child := range children { |
| 217 | + err = RestoreAssets(dir, path.Join(name, child)) |
| 218 | + if err != nil { |
| 219 | + return err |
| 220 | + } |
| 221 | + } |
| 222 | + } |
| 223 | + return nil |
| 224 | +} |
| 225 | + |
| 226 | +func _filePath(dir, name string) string { |
| 227 | + cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 228 | + return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) |
| 229 | +} |
| 230 | + |
0 commit comments