From 4ca59a010e42978d168a6c92335557a088284b99 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 13 Mar 2012 13:48:07 +0800 Subject: [PATCH] os: remove document duplication in error predicate functions R=golang-dev, r CC=golang-dev https://golang.org/cl/5783092 --- src/pkg/os/error.go | 18 ++++++++++++++++++ src/pkg/os/error_plan9.go | 9 +++------ src/pkg/os/error_posix.go | 12 +++--------- src/pkg/os/error_windows.go | 12 +++--------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/pkg/os/error.go b/src/pkg/os/error.go index e0b83b5c22..54c2dc6399 100644 --- a/src/pkg/os/error.go +++ b/src/pkg/os/error.go @@ -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) +} diff --git a/src/pkg/os/error_plan9.go b/src/pkg/os/error_plan9.go index 159d685e7c..3c9dfb0b15 100644 --- a/src/pkg/os/error_plan9.go +++ b/src/pkg/os/error_plan9.go @@ -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 } diff --git a/src/pkg/os/error_posix.go b/src/pkg/os/error_posix.go index d08ad5db16..1685c1f213 100644 --- a/src/pkg/os/error_posix.go +++ b/src/pkg/os/error_posix.go @@ -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 } diff --git a/src/pkg/os/error_windows.go b/src/pkg/os/error_windows.go index 84bf5eae8a..b8b894b5a2 100644 --- a/src/pkg/os/error_windows.go +++ b/src/pkg/os/error_windows.go @@ -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 } -- 2.50.0