diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-02 20:01:37 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-02 20:01:37 +0000 |
commit | ef10b1dda693467283a3645a5da610e810149764 (patch) | |
tree | 3eeb8918d39d675108073c8b76d6dd10586a608c /libgo/go/os/error_posix.go | |
parent | ea6ad4ae9afbd45b5c19aadab39ddbf1db0d50f8 (diff) | |
download | gcc-ef10b1dda693467283a3645a5da610e810149764.tar.gz |
libgo: Update to weekly.2012-02-22 release.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184819 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/os/error_posix.go')
-rw-r--r-- | libgo/go/os/error_posix.go | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/libgo/go/os/error_posix.go b/libgo/go/os/error_posix.go index 57c9b6f2786..74b75d11218 100644 --- a/libgo/go/os/error_posix.go +++ b/libgo/go/os/error_posix.go @@ -8,44 +8,29 @@ package os import "syscall" -// Commonly known Unix errors. -var ( - EPERM error = syscall.EPERM - ENOENT error = syscall.ENOENT - ESRCH error = syscall.ESRCH - EINTR error = syscall.EINTR - EIO error = syscall.EIO - E2BIG error = syscall.E2BIG - ENOEXEC error = syscall.ENOEXEC - EBADF error = syscall.EBADF - ECHILD error = syscall.ECHILD - EDEADLK error = syscall.EDEADLK - ENOMEM error = syscall.ENOMEM - EACCES error = syscall.EACCES - EFAULT error = syscall.EFAULT - EBUSY error = syscall.EBUSY - EEXIST error = syscall.EEXIST - EXDEV error = syscall.EXDEV - ENODEV error = syscall.ENODEV - ENOTDIR error = syscall.ENOTDIR - EISDIR error = syscall.EISDIR - EINVAL error = syscall.EINVAL - ENFILE error = syscall.ENFILE - EMFILE error = syscall.EMFILE - ENOTTY error = syscall.ENOTTY - EFBIG error = syscall.EFBIG - ENOSPC error = syscall.ENOSPC - ESPIPE error = syscall.ESPIPE - EROFS error = syscall.EROFS - EMLINK error = syscall.EMLINK - EPIPE error = syscall.EPIPE - EAGAIN error = syscall.EAGAIN - EDOM error = syscall.EDOM - ERANGE error = syscall.ERANGE - EADDRINUSE error = syscall.EADDRINUSE - ECONNREFUSED error = syscall.ECONNREFUSED - ENAMETOOLONG error = syscall.ENAMETOOLONG - EAFNOSUPPORT error = syscall.EAFNOSUPPORT - ETIMEDOUT error = syscall.ETIMEDOUT - ENOTCONN error = syscall.ENOTCONN -) +// IsExist returns whether the error is known to report that a file already exists. +// It is satisfied by ErrExist as well as some syscall errors. +func IsExist(err error) bool { + if pe, ok := err.(*PathError); ok { + err = pe.Err + } + return err == syscall.EEXIST || err == ErrExist +} + +// IsNotExist returns whether the error is known to report that a file does not exist. +// It is satisfied by ErrNotExist as well as some syscall errors. +func IsNotExist(err error) bool { + if pe, ok := err.(*PathError); ok { + err = pe.Err + } + return err == syscall.ENOENT || err == ErrNotExist +} + +// IsPermission returns whether the error is known to report that permission is denied. +// It is satisfied by ErrPermission as well as some syscall errors. +func IsPermission(err error) bool { + if pe, ok := err.(*PathError); ok { + err = pe.Err + } + return err == syscall.EACCES || err == syscall.EPERM || err == ErrPermission +} |