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.
7 func isExist(err error) bool {
8 return checkErrMessageContent(err, "exists", "is a directory")
11 func isNotExist(err error) bool {
12 return checkErrMessageContent(err, "does not exist", "not found",
13 "has been removed", "no parent")
16 func isPermission(err error) bool {
17 return checkErrMessageContent(err, "permission denied")
20 // checkErrMessageContent checks if err message contains one of msgs.
21 func checkErrMessageContent(err error, msgs ...string) bool {
25 err = underlyingError(err)
26 for _, msg := range msgs {
27 if contains(err.Error(), msg) {
34 // contains is a local version of strings.Contains. It knows len(sep) > 1.
35 func contains(s, sep string) bool {
38 for i := 0; i+n <= len(s); i++ {
39 if s[i] == c && s[i:i+n] == sep {