Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4ca59a01
Commit
4ca59a01
authored
Mar 13, 2012
by
Shenghou Ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os: remove document duplication in error predicate functions
R=golang-dev, r CC=golang-dev
https://golang.org/cl/5783092
parent
e24d99d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
24 deletions
+27
-24
src/pkg/os/error.go
src/pkg/os/error.go
+18
-0
src/pkg/os/error_plan9.go
src/pkg/os/error_plan9.go
+3
-6
src/pkg/os/error_posix.go
src/pkg/os/error_posix.go
+3
-9
src/pkg/os/error_windows.go
src/pkg/os/error_windows.go
+3
-9
No files found.
src/pkg/os/error.go
View file @
4ca59a01
...
...
@@ -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
)
}
src/pkg/os/error_plan9.go
View file @
4ca59a01
...
...
@@ -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
}
...
...
src/pkg/os/error_posix.go
View file @
4ca59a01
...
...
@@ -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
}
...
...
src/pkg/os/error_windows.go
View file @
4ca59a01
...
...
@@ -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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment