forked from kevinburke/go-bindata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.go
53 lines (44 loc) · 888 Bytes
/
embed.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
package xbindata
import (
"fmt"
"io"
"os"
"path/filepath"
)
func outlinedHeadersWrite(w io.Writer, toc []Asset, c *Config) (err error) {
fn := "StoreFile"
if c.OutlinedNoTruncate {
fn = "Append"
}
if !c.NoCompress {
fn += "Gz"
}
data := `package main
import (
"os"
"time"
bc "github.com/moisespsena-go/xbindata/xbcommon"
"github.com/moisespsena-go/xbindata/outlined"
)
func main() {
for _, dest := range os.Args[1:] {
if err := headers.` + fn + `(dest); err != nil {
panic(err)
}
}
}
var headers = outlined.Headers{
`
cwd, _ := os.Getwd()
for _, asset := range toc {
info, _ := asset.InfoExport(c)
rpth, err := filepath.Rel(cwd, asset.Path)
if err != nil {
rpth = asset.Path
}
data += fmt.Sprintf("\toutlined.NewHeader(bc.NewFileInfo(%q, %s), %q),\n", asset.Name, info, rpth)
}
data += "}\n"
_, err = w.Write([]byte(data))
return
}