-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.go
45 lines (37 loc) · 737 Bytes
/
common.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
package main
const cowAlignment = 4096
const cowMask = cowAlignment - 1
const cowMagic = "CAR!"
const entrySize = 4 + 8 + 8 + 2
const EOR = 0xffffffff
var zeroes = make([]byte, cowAlignment)
type fixedData struct {
Mode uint32
Offset uint64
Size uint64
NameLength uint16
}
type entry struct {
fixedData
name string
localName string
link string
linkLen uint16
hash uint64
}
type header struct {
entries []*entry
Size uint64
}
type archive interface {
archive(paths []string, outFile string) error
extract(inFile string) error
}
type car struct {
dupMap map[uint64]*fixedData
verbose *bool
header header
}
func round4k(Size uint64) uint64 {
return ((Size - 1) | 0xfff) + 1
}