Commit 35367cc6 authored by Rob Pike's avatar Rob Pike

mime: use Scanner to read mime files during init

Also close the file when we're done.

R=bradfitz
CC=golang-dev
https://golang.org/cl/7363045
parent cbd2c7a2
......@@ -23,15 +23,11 @@ func loadMimeFile(filename string) {
if err != nil {
return
}
defer f.Close()
reader := bufio.NewReader(f)
for {
line, err := reader.ReadString('\n')
if err != nil {
f.Close()
return
}
fields := strings.Fields(line)
scanner := bufio.NewScanner(f)
for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if len(fields) <= 1 || fields[0][0] == '#' {
continue
}
......@@ -43,6 +39,9 @@ func loadMimeFile(filename string) {
setExtensionType("."+ext, mimeType)
}
}
if err := scanner.Err(); err != nil {
panic(err)
}
}
func initMime() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment