repochecker/*-inspector: Refactor file opening
This commit is contained in:
parent
257c594dbe
commit
14f10c91db
4 changed files with 31 additions and 31 deletions
|
@ -110,20 +110,12 @@ func CheckTextFile(fd *os.File) (errs []error) {
|
|||
}
|
||||
|
||||
func InspectFileForIPAddr(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error) {
|
||||
i, ok := sync.GlobalImporter.(sync.LocalImporter)
|
||||
if !ok {
|
||||
log.Printf("Unable to load `pcap-inspector.so` as the current Importer is not a LocalImporter (%T).", sync.GlobalImporter)
|
||||
return
|
||||
}
|
||||
|
||||
path := i.GetLocalPath(file.GetOrigin())
|
||||
|
||||
fd, err := os.Open(path)
|
||||
fd, closer, err := sync.GetFile(sync.GlobalImporter, file.GetOrigin())
|
||||
if err != nil {
|
||||
log.Printf("Unable to open %q: %s", path, err.Error())
|
||||
log.Printf("Unable to open %q: %s", file.GetOrigin(), err.Error())
|
||||
return
|
||||
}
|
||||
defer fd.Close()
|
||||
defer closer()
|
||||
|
||||
switch filepath.Ext(file.Name) {
|
||||
case ".pcap":
|
||||
|
|
Reference in a new issue