aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/os
diff options
context:
space:
mode:
authorPatrick Mézard <patrick@mezard.eu>2014-03-05 12:19:56 +1100
committerAlex Brainman <alex.brainman@gmail.com>2014-03-05 12:19:56 +1100
commit9a7cd11bc8f1763710a18bd90e9db00f8281d69b (patch)
tree55bfd1d07e7bd419024cec9e325d28a2b627dae6 /src/pkg/os
parent1624c73c9d98ad3466db0648a8462e8720cfa4aa (diff)
downloadgo-9a7cd11bc8f1763710a18bd90e9db00f8281d69b.tar.xz
os: try openFile before openDir in windows os.OpenFile
Logging calls when running "go install -a std" turns: 547 openDir succeeded 3593 openDir failed and fell back to openFile 3592 openFile succeeded 1 both failed into: 3592 openFile succeeded 548 openFile failed and fell back 547 openDir succeeded 1 both failed Here the change trades 3593 failed openDir for 548 failed openFile. Fix issue 7426. LGTM=alex.brainman R=golang-codereviews, alex.brainman, bradfitz CC=golang-codereviews https://golang.org/cl/70480044
Diffstat (limited to 'src/pkg/os')
-rw-r--r--src/pkg/os/file_windows.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/pkg/os/file_windows.go b/src/pkg/os/file_windows.go
index fab7de3428..efe8bc03fc 100644
--- a/src/pkg/os/file_windows.go
+++ b/src/pkg/os/file_windows.go
@@ -134,20 +134,19 @@ func OpenFile(name string, flag int, perm FileMode) (file *File, err error) {
if name == "" {
return nil, &PathError{"open", name, syscall.ENOENT}
}
- // TODO(brainman): not sure about my logic of assuming it is dir first, then fall back to file
- r, e := openDir(name)
- if e == nil {
+ r, errf := openFile(name, flag, perm)
+ if errf == nil {
+ return r, nil
+ }
+ r, errd := openDir(name)
+ if errd == nil {
if flag&O_WRONLY != 0 || flag&O_RDWR != 0 {
r.Close()
return nil, &PathError{"open", name, syscall.EISDIR}
}
return r, nil
}
- r, e = openFile(name, flag, perm)
- if e == nil {
- return r, nil
- }
- return nil, &PathError{"open", name, e}
+ return nil, &PathError{"open", name, errf}
}
// Close closes the File, rendering it unusable for I/O.