Commit 4ca59a01 authored by Shenghou Ma's avatar Shenghou Ma

os: remove document duplication in error predicate functions

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5783092
parent e24d99d0
......@@ -42,3 +42,21 @@ func NewSyscallError(syscall string, err error) error {
}
return &SyscallError{syscall, err}
}
// 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 {
return isExist(err)
}
// 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 {
return isNotExist(err)
}
// 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 {
return isPermission(err)
}
......@@ -4,24 +4,21 @@
package os
// IsExist returns whether the error is known to report that a file already exists.
func IsExist(err error) bool {
func isExist(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
return contains(err.Error(), " exists")
}
// IsNotExist returns whether the error is known to report that a file does not exist.
func IsNotExist(err error) bool {
func isNotExist(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
return contains(err.Error(), "does not exist")
}
// IsPermission returns whether the error is known to report that permission is denied.
func IsPermission(err error) bool {
func isPermission(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
......
......@@ -8,27 +8,21 @@ package os
import "syscall"
// 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 {
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 {
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 {
func isPermission(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
......
......@@ -6,9 +6,7 @@ package os
import "syscall"
// 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 {
func isExist(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
......@@ -16,18 +14,14 @@ func IsExist(err error) bool {
err == syscall.ERROR_FILE_EXISTS || 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 {
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 {
func isPermission(err error) bool {
if pe, ok := err.(*PathError); ok {
err = pe.Err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment