diff options
Diffstat (limited to 'libgo/go/os/file.go')
-rw-r--r-- | libgo/go/os/file.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libgo/go/os/file.go b/libgo/go/os/file.go index e12428cbe12..8c0e3ffe1ba 100644 --- a/libgo/go/os/file.go +++ b/libgo/go/os/file.go @@ -192,7 +192,7 @@ func (f *File) Seek(offset int64, whence int) (ret int64, err error) { // WriteString is like Write, but writes the contents of string s rather than // a slice of bytes. -func (f *File) WriteString(s string) (ret int, err error) { +func (f *File) WriteString(s string) (n int, err error) { if f == nil { return 0, ErrInvalid } @@ -203,9 +203,16 @@ func (f *File) WriteString(s string) (ret int, err error) { // If there is an error, it will be of type *PathError. func Mkdir(name string, perm FileMode) error { e := syscall.Mkdir(name, syscallMode(perm)) + if e != nil { return &PathError{"mkdir", name, e} } + + // mkdir(2) itself won't handle the sticky bit on *BSD and Solaris + if !supportsCreateWithStickyBit && perm&ModeSticky != 0 { + Chmod(name, perm) + } + return nil } @@ -235,16 +242,16 @@ func (f *File) Chdir() error { // the returned file can be used for reading; the associated file // descriptor has mode O_RDONLY. // If there is an error, it will be of type *PathError. -func Open(name string) (file *File, err error) { +func Open(name string) (*File, error) { return OpenFile(name, O_RDONLY, 0) } -// Create creates the named file mode 0666 (before umask), truncating -// it if it already exists. If successful, methods on the returned +// Create creates the named file with mode 0666 (before umask), truncating +// it if it already exists. If successful, methods on the returned // File can be used for I/O; the associated file descriptor has mode // O_RDWR. // If there is an error, it will be of type *PathError. -func Create(name string) (file *File, err error) { +func Create(name string) (*File, error) { return OpenFile(name, O_RDWR|O_CREATE|O_TRUNC, 0666) } @@ -252,6 +259,7 @@ func Create(name string) (file *File, err error) { var lstat = Lstat // Rename renames (moves) a file. OS-specific restrictions might apply. +// If there is an error, it will be of type *LinkError. func Rename(oldpath, newpath string) error { return rename(oldpath, newpath) } |