Skip to content

Commit

Permalink
fix: ffi match reader
Browse files Browse the repository at this point in the history
  • Loading branch information
redraskal committed Feb 22, 2024
1 parent 5621b9b commit f1c8e04
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions exports/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ func convertErrorForExport(err error) string {
func dissect_read(input *C.char) *C.char {
zerolog.SetGlobalLevel(zerolog.Disabled)
path := C.GoString(input)
s, err := os.Stat(path)
f, err := os.Open(path)
if err != nil {
res := convertErrorForExport(err)
return C.CString(res)
}
defer f.Close()
s, err := f.Stat()
if err != nil {
res := convertErrorForExport(err)
return C.CString(res)
}
if s.IsDir() {
m, err := dissect.NewMatchReader(path)
m, err := dissect.NewMatchReader(f)
if err != nil {
res := convertErrorForExport(err)
return C.CString(res)
Expand All @@ -62,12 +68,6 @@ func dissect_read(input *C.char) *C.char {
res := convertForExport(j)
return C.CString(res)
} else {
f, err := os.Open(path)
if err != nil {
res := convertErrorForExport(err)
return C.CString(res)
}
defer f.Close()
r, err := dissect.NewReader(f)
if err != nil {
res := convertErrorForExport(err)
Expand Down

0 comments on commit f1c8e04

Please sign in to comment.