Use filename instead of file handler to scan file for null byte
This commit is contained in:
@@ -32,13 +32,21 @@ func genRange[T character](start, end T) []T {
|
||||
}
|
||||
|
||||
// Returns whether or not the given file contains a NULL character
|
||||
func fileContainsNullChar(file *os.File) bool {
|
||||
func fileContainsNullChar(filename string) (bool, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
defer file.Close()
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.Contains(line, "\000") {
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false
|
||||
if err := scanner.Err(); err != nil {
|
||||
return true, err
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user