MCPcopy
hub / github.com/davyxu/tabtoy / Run

Method Run

v2/printer/binary.go:16–53  ·  view source on GitHub ↗
(g *Globals)

Source from the content-addressed store, hash-verified

14}
15
16func (self *binaryPrinter) Run(g *Globals) *Stream {
17
18 fileStresam := NewStream()
19 fileStresam.WriteString("TT")
20 fileStresam.WriteInt32(combineFileVersion)
21 fileStresam.WriteString(g.BuildID)
22
23 const md5base64Len = 32
24
25 beginPos := fileStresam.Buffer().Len() + 4
26 fileStresam.WriteString(strings.Repeat("Z", md5base64Len))
27 dataPos := fileStresam.Buffer().Len()
28
29 for index, tab := range g.Tables {
30
31 if !tab.LocalFD.MatchTag(".bin") {
32 log.Infof("%s: %s", i18n.String(i18n.Printer_IgnoredByOutputTag), tab.Name())
33 continue
34 }
35
36 if !writeTableBinary(fileStresam, tab, int32(index)) {
37 return nil
38 }
39
40 }
41
42 m := md5.New()
43 m.Write([]byte(fileStresam.Buffer().Bytes()[dataPos:]))
44
45 checksum := hex.EncodeToString(m.Sum(nil))
46
47 checkSumData := fileStresam.Buffer().Bytes()[beginPos : beginPos+32]
48
49 // 回填checksum
50 copy(checkSumData, []byte(checksum))
51
52 return fileStresam
53}
54
55func writeTableBinary(tabStream *Stream, tab *model.Table, index int32) bool {
56

Callers

nothing calls this directly

Calls 11

WriteStringMethod · 0.95
WriteInt32Method · 0.95
BufferMethod · 0.95
StringFunction · 0.92
NewStreamFunction · 0.85
writeTableBinaryFunction · 0.85
MatchTagMethod · 0.80
WriteMethod · 0.80
BytesMethod · 0.80
NameMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected