Daily bump.
[official-gcc.git] / libgo / go / os / error_plan9.go
blob85260c82aeab651d07222c5b16390d655e1d869a
1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package os
7 func isExist(err error) bool {
8 switch pe := err.(type) {
9 case nil:
10 return false
11 case *PathError:
12 err = pe.Err
13 case *LinkError:
14 err = pe.Err
16 return contains(err.Error(), " exists")
19 func isNotExist(err error) bool {
20 switch pe := err.(type) {
21 case nil:
22 return false
23 case *PathError:
24 err = pe.Err
25 case *LinkError:
26 err = pe.Err
28 return contains(err.Error(), "does not exist")
31 func isPermission(err error) bool {
32 switch pe := err.(type) {
33 case nil:
34 return false
35 case *PathError:
36 err = pe.Err
37 case *LinkError:
38 err = pe.Err
40 return contains(err.Error(), "permission denied")
43 // contains is a local version of strings.Contains. It knows len(sep) > 1.
44 func contains(s, sep string) bool {
45 n := len(sep)
46 c := sep[0]
47 for i := 0; i+n <= len(s); i++ {
48 if s[i] == c && s[i:i+n] == sep {
49 return true
52 return false