|
|
@ -32,13 +32,21 @@ func genRange[T character](start, end T) []T {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns whether or not the given file contains a NULL character
|
|
|
|
// 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)
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
|
|
for scanner.Scan() {
|
|
|
|
for scanner.Scan() {
|
|
|
|
line := scanner.Text()
|
|
|
|
line := scanner.Text()
|
|
|
|
if strings.Contains(line, "\000") {
|
|
|
|
if strings.Contains(line, "\000") {
|
|
|
|
return true
|
|
|
|
return true, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
|
|
|
|
return true, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|