-
Notifications
You must be signed in to change notification settings - Fork 1
/
siegfried.go
44 lines (34 loc) · 855 Bytes
/
siegfried.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
package filedriller
import (
"github.com/richardlehane/siegfried"
//"log"
"os"
"strconv"
)
func siegfriedIdent(s *siegfried.Siegfried, inFile string) (bool, string) {
var oneFile string
var resultBool bool
f, err := os.Open(inFile)
if err != nil {
return resultBool, err.Error()
}
defer f.Close()
fi, _ := f.Stat()
if fi.Size() == 0 {
//return resultBool, "\"" + inFile + "\",0,,,,,,,"
return true, "\"" + inFile + "\",0,,,,,,,"
}
ids, err := s.Identify(f, "", "")
if err != nil {
ret := inFile + " : " + err.Error()
return resultBool, ret
}
for _, id := range ids {
values := id.Values()
for _, value := range values {
oneFile += "\"" + value + "\"" + ","
}
oneFile = "\"" + inFile + "\",\"" + strconv.Itoa(int(fi.Size())) + "\"," + oneFile[:len(oneFile)-1] // remove last comma
}
return true, oneFile
}