mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)
This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)
The interesting packages are:
gofix
os
Everything else is automatically generated except for hand tweaks to:
src/pkg/io/ioutil/ioutil.go
src/pkg/io/ioutil/tempfile.go
src/pkg/crypto/tls/generate_cert.go
src/cmd/goyacc/goyacc.go
src/cmd/goyacc/units.y
R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
This commit is contained in:
parent
3ebc422ff8
commit
8a90fd3c72
59 changed files with 291 additions and 106 deletions
|
|
@ -20,10 +20,12 @@ type dirInfo struct {
|
|||
// On Unix-like systems, it is "/dev/null"; on Windows, "NUL".
|
||||
const DevNull = "/dev/null"
|
||||
|
||||
// Open opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.)
|
||||
// if applicable. If successful, methods on the returned File can be used for I/O.
|
||||
// OpenFile is the generalized open call; most users will use Open
|
||||
// or Create instead. It opens the named file with specified flag
|
||||
// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful,
|
||||
// methods on the returned File can be used for I/O.
|
||||
// It returns the File and an Error, if any.
|
||||
func Open(name string, flag int, perm uint32) (file *File, err Error) {
|
||||
func OpenFile(name string, flag int, perm uint32) (file *File, err Error) {
|
||||
r, e := syscall.Open(name, flag|syscall.O_CLOEXEC, perm)
|
||||
if e != 0 {
|
||||
return nil, &PathError{"open", name, Errno(e)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue