Commit 4b05dc91 authored by Ian Lance Taylor's avatar Ian Lance Taylor

os: clarify that mode argument is only used if file is created

Fixes #30400

Change-Id: Icbd1dda29562afa80c8e37657133a6fe48070ac0
Reviewed-on: https://go-review.googlesource.com/c/163744Reviewed-by: default avatarRob Pike <r@golang.org>
parent dc045522
...@@ -265,10 +265,10 @@ func Open(name string) (*File, error) { ...@@ -265,10 +265,10 @@ func Open(name string) (*File, error) {
return OpenFile(name, O_RDONLY, 0) return OpenFile(name, O_RDONLY, 0)
} }
// Create creates the named file with mode 0666 (before umask), truncating // Create creates or truncates the named file. If the file already exists,
// it if it already exists. If successful, methods on the returned // it is truncated. If the file does not exist, it is created with mode 0666
// File can be used for I/O; the associated file descriptor has mode // (before umask). If successful, methods on the returned File can
// O_RDWR. // be used for I/O; the associated file descriptor has mode O_RDWR.
// If there is an error, it will be of type *PathError. // If there is an error, it will be of type *PathError.
func Create(name string) (*File, error) { func Create(name string) (*File, error) {
return OpenFile(name, O_RDWR|O_CREATE|O_TRUNC, 0666) return OpenFile(name, O_RDWR|O_CREATE|O_TRUNC, 0666)
...@@ -276,7 +276,8 @@ func Create(name string) (*File, error) { ...@@ -276,7 +276,8 @@ func Create(name string) (*File, error) {
// OpenFile is the generalized open call; most users will use Open // OpenFile is the generalized open call; most users will use Open
// or Create instead. It opens the named file with specified flag // or Create instead. It opens the named file with specified flag
// (O_RDONLY etc.) and perm (before umask), if applicable. If successful, // (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag
// is passed, it is created with mode perm (before umask). If successful,
// methods on the returned File can be used for I/O. // methods on the returned File can be used for I/O.
// If there is an error, it will be of type *PathError. // If there is an error, it will be of type *PathError.
func OpenFile(name string, flag int, perm FileMode) (*File, error) { func OpenFile(name string, flag int, perm FileMode) (*File, error) {
......
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