-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.go
35 lines (28 loc) · 669 Bytes
/
header.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
package main
var HEADER = "\xf5\x00"
var HEADER_ENCRYPTED = "\xf4\xc2"
func (bas *AmigaBasicFile) extractHeader() {
headerSize := 4
if len(bas.BinaryData) < 1 {
headerSize = 0
} else if len(bas.BinaryData) < 6 {
headerSize = 1
}
bas.header.data = bas.BinaryData[:headerSize]
}
type AmigaBasicFileHeader struct {
data []byte
}
func (h AmigaBasicFileHeader) isValid() bool {
if len(h.data) == 0 {
return true
}
return len(h.data) > 0 &&
h.data[0] == HEADER[0] &&
h.data[1] == HEADER[1]
}
func (h AmigaBasicFileHeader) isEncryptedBody() bool {
return len(h.data) > 0 &&
h.data[0] == HEADER_ENCRYPTED[0] &&
h.data[1] == HEADER_ENCRYPTED[1]
}