summaryrefslogtreecommitdiff
path: root/src/pkg/os/file_posix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/file_posix.go')
-rw-r--r--src/pkg/os/file_posix.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pkg/os/file_posix.go b/src/pkg/os/file_posix.go
index 3df43feaa..a8bef359b 100644
--- a/src/pkg/os/file_posix.go
+++ b/src/pkg/os/file_posix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin freebsd linux netbsd openbsd windows
+// +build darwin dragonfly freebsd linux netbsd openbsd windows
package os
@@ -86,6 +86,9 @@ func Chmod(name string, mode FileMode) error {
// Chmod changes the mode of the file to mode.
// If there is an error, it will be of type *PathError.
func (f *File) Chmod(mode FileMode) error {
+ if f == nil {
+ return ErrInvalid
+ }
if e := syscall.Fchmod(f.fd, syscallMode(mode)); e != nil {
return &PathError{"chmod", f.name, e}
}
@@ -115,6 +118,9 @@ func Lchown(name string, uid, gid int) error {
// Chown changes the numeric uid and gid of the named file.
// If there is an error, it will be of type *PathError.
func (f *File) Chown(uid, gid int) error {
+ if f == nil {
+ return ErrInvalid
+ }
if e := syscall.Fchown(f.fd, uid, gid); e != nil {
return &PathError{"chown", f.name, e}
}
@@ -125,6 +131,9 @@ func (f *File) Chown(uid, gid int) error {
// It does not change the I/O offset.
// If there is an error, it will be of type *PathError.
func (f *File) Truncate(size int64) error {
+ if f == nil {
+ return ErrInvalid
+ }
if e := syscall.Ftruncate(f.fd, size); e != nil {
return &PathError{"truncate", f.name, e}
}