Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(468)

Unified Diff: src/cmd/godoc/codewalk.go

Issue 4572065: code review 4572065: godoc: replace direct OS file system accesses in favor (Closed)
Patch Set: diff -r d086bab9b037 https://go.googlecode.com/hg/ Created 12 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/godoc/Makefile ('k') | src/cmd/godoc/dirtrees.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/godoc/codewalk.go
===================================================================
--- a/src/cmd/godoc/codewalk.go
+++ b/src/cmd/godoc/codewalk.go
@@ -17,7 +17,6 @@
"fmt"
"http"
"io"
- "io/ioutil"
"log"
"os"
"regexp"
@@ -42,7 +41,7 @@
}
// If directory exists, serve list of code walks.
- dir, err := os.Lstat(abspath)
+ dir, err := fs.Lstat(abspath)
if err == nil && dir.IsDirectory() {
codewalkDir(w, r, relpath, abspath)
return
@@ -114,8 +113,8 @@
// loadCodewalk reads a codewalk from the named XML file.
-func loadCodewalk(file string) (*Codewalk, os.Error) {
- f, err := os.Open(file)
+func loadCodewalk(filename string) (*Codewalk, os.Error) {
+ f, err := fs.Open(filename)
if err != nil {
return nil, err
}
@@ -125,7 +124,7 @@
p.Entity = xml.HTMLEntity
err = p.Unmarshal(cw, nil)
if err != nil {
- return nil, &os.PathError{"parsing", file, err}
+ return nil, &os.PathError{"parsing", filename, err}
}
// Compute file list, evaluate line numbers for addresses.
@@ -135,8 +134,8 @@
if i < 0 {
i = len(st.Src)
}
- file := st.Src[0:i]
- data, err := ioutil.ReadFile(absolutePath(file, *goroot))
+ filename := st.Src[0:i]
+ data, err := fs.ReadFile(absolutePath(filename, *goroot))
if err != nil {
st.Err = err
continue
@@ -158,8 +157,8 @@
st.Hi = byteToLine(data, hi-1)
}
st.Data = data
- st.File = file
- m[file] = true
+ st.File = filename
+ m[filename] = true
}
// Make list of files
@@ -184,7 +183,7 @@
Title string
}
- dir, err := ioutil.ReadDir(abspath)
+ dir, err := fs.ReadDir(abspath)
if err != nil {
log.Print(err)
serveError(w, r, relpath, err)
@@ -192,14 +191,15 @@
}
var v vector.Vector
for _, fi := range dir {
+ name := fi.Name()
if fi.IsDirectory() {
- v.Push(&elem{fi.Name + "/", ""})
- } else if strings.HasSuffix(fi.Name, ".xml") {
- cw, err := loadCodewalk(abspath + "/" + fi.Name)
+ v.Push(&elem{name + "/", ""})
+ } else if strings.HasSuffix(name, ".xml") {
+ cw, err := loadCodewalk(abspath + "/" + name)
if err != nil {
continue
}
- v.Push(&elem{fi.Name[0 : len(fi.Name)-len(".xml")], cw.Title})
+ v.Push(&elem{name[0 : len(name)-len(".xml")], cw.Title})
}
}
@@ -216,7 +216,7 @@
// the usual godoc HTML wrapper.
func codewalkFileprint(w http.ResponseWriter, r *http.Request, f string) {
abspath := absolutePath(f, *goroot)
- data, err := ioutil.ReadFile(abspath)
+ data, err := fs.ReadFile(abspath)
if err != nil {
log.Print(err)
serveError(w, r, f, err)
« no previous file with comments | « src/cmd/godoc/Makefile ('k') | src/cmd/godoc/dirtrees.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b