github.com/ccccaoqing/test@v0.0.0-20220510085219-3985d23445c0/src/os/error_unix.go (about) 1 // Copyright 2009 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. 4 5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 7 package os 8 9 import "syscall" 10 11 func isExist(err error) bool { 12 switch pe := err.(type) { 13 case nil: 14 return false 15 case *PathError: 16 err = pe.Err 17 case *LinkError: 18 err = pe.Err 19 } 20 return err == syscall.EEXIST || err == ErrExist 21 } 22 23 func isNotExist(err error) bool { 24 switch pe := err.(type) { 25 case nil: 26 return false 27 case *PathError: 28 err = pe.Err 29 case *LinkError: 30 err = pe.Err 31 } 32 return err == syscall.ENOENT || err == ErrNotExist 33 } 34 35 func isPermission(err error) bool { 36 switch pe := err.(type) { 37 case nil: 38 return false 39 case *PathError: 40 err = pe.Err 41 case *LinkError: 42 err = pe.Err 43 } 44 return err == syscall.EACCES || err == syscall.EPERM || err == ErrPermission 45 }