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

Delta Between Two Patch Sets: src/pkg/os/error_posix.go

Issue 6442080: code review 6442080: os: test that IsExist and IsNotExist handle PathError a... (Closed)
Left Patch Set: diff -r af9e9fe6bc5a https://go.googlecode.com/hg/ Created 12 years, 8 months ago
Right Patch Set: diff -r c74762fb2e1d https://go.googlecode.com/hg/ Created 12 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/os/error_plan9.go ('k') | src/pkg/os/error_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd 5 // +build darwin freebsd linux netbsd openbsd
6 6
7 package os 7 package os
8 8
9 import "syscall" 9 import "syscall"
10 10
11 func isExist(err error) bool { 11 func isExist(err error) bool {
12 » if pe, ok := err.(*PathError); ok { 12 » switch pe := err.(type) {
13 » case nil:
14 » » return false
15 » case *PathError:
13 err = pe.Err 16 err = pe.Err
14 » } 17 » case *LinkError:
15 » if pe, ok := err.(*LinkError); ok {
16 err = pe.Err 18 err = pe.Err
17 } 19 }
18 return err == syscall.EEXIST || err == ErrExist 20 return err == syscall.EEXIST || err == ErrExist
19 } 21 }
20 22
21 func isNotExist(err error) bool { 23 func isNotExist(err error) bool {
22 » if pe, ok := err.(*PathError); ok { 24 » switch pe := err.(type) {
25 » case nil:
26 » » return false
27 » case *PathError:
23 err = pe.Err 28 err = pe.Err
24 » } 29 » case *LinkError:
25 » if pe, ok := err.(*LinkError); ok {
26 err = pe.Err 30 err = pe.Err
27 } 31 }
28 return err == syscall.ENOENT || err == ErrNotExist 32 return err == syscall.ENOENT || err == ErrNotExist
29 } 33 }
30 34
31 func isPermission(err error) bool { 35 func isPermission(err error) bool {
32 » if pe, ok := err.(*PathError); ok { 36 » switch pe := err.(type) {
37 » case nil:
38 » » return false
39 » case *PathError:
33 err = pe.Err 40 err = pe.Err
34 » } 41 » case *LinkError:
35 » if pe, ok := err.(*LinkError); ok {
36 err = pe.Err 42 err = pe.Err
37 } 43 }
38 return err == syscall.EACCES || err == syscall.EPERM || err == ErrPermis sion 44 return err == syscall.EACCES || err == syscall.EPERM || err == ErrPermis sion
39 } 45 }
LEFTRIGHT

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