-
Notifications
You must be signed in to change notification settings - Fork 2
/
psp_entry_type.go
49 lines (42 loc) · 929 Bytes
/
psp_entry_type.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
package pspentrytype
import (
"bufio"
"encoding/csv"
"io"
"log"
"os"
"path/filepath"
"runtime"
"strconv"
)
type AMDPSPDirectoryEntryType struct {
Type uint32
Name string
ProposedName string
Comment string
}
func Types() []AMDPSPDirectoryEntryType {
_, filename, _, _ := runtime.Caller(0)
fpath := filepath.Dir(filename)
fpath = filepath.Join(fpath, "types.csv")
csvFile, _ := os.Open(fpath)
reader := csv.NewReader(bufio.NewReader(csvFile))
reader.Read()
var entryTypes []AMDPSPDirectoryEntryType
for {
line, error := reader.Read()
if error == io.EOF {
break
} else if error != nil {
log.Fatal("Could not read csv: ", error)
}
id, _ := strconv.ParseInt(line[0], 0, 64)
entryTypes = append(entryTypes, AMDPSPDirectoryEntryType{
Type: uint32(id),
Name: line[1],
ProposedName: line[2],
Comment: line[3],
})
}
return entryTypes
}