diff options
| author | Peter Mundy <go.peter.90@gmail.com> | 2010-08-03 13:03:50 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2010-08-03 13:03:50 -0700 |
| commit | 12befd063b3be0b46e7385f4ad98e8effe87c0e7 (patch) | |
| tree | b124a0a41f7dbd8de7fbd5baa96b5502f49f5d29 /src | |
| parent | 311973ea5679e460cecf04193e80e8baf4bbc324 (diff) | |
| download | go-12befd063b3be0b46e7385f4ad98e8effe87c0e7.tar.xz | |
os: Null device
R=rsc, cw
CC=golang-dev
https://golang.org/cl/1854042
Diffstat (limited to 'src')
| -rw-r--r-- | src/pkg/exec/exec.go | 2 | ||||
| -rw-r--r-- | src/pkg/os/file_unix.go | 4 | ||||
| -rw-r--r-- | src/pkg/os/file_windows.go | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/pkg/exec/exec.go b/src/pkg/exec/exec.go index ee3cec686b..e1c49004f7 100644 --- a/src/pkg/exec/exec.go +++ b/src/pkg/exec/exec.go @@ -39,7 +39,7 @@ func modeToFiles(mode, fd int) (*os.File, *os.File, os.Error) { if fd == 0 { rw = os.O_RDONLY } - f, err := os.Open("/dev/null", rw, 0) + f, err := os.Open(os.DevNull, rw, 0) return f, nil, err case PassThrough: switch fd { diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go index 6cf2661406..76033c3e39 100644 --- a/src/pkg/os/file_unix.go +++ b/src/pkg/os/file_unix.go @@ -18,6 +18,10 @@ type dirInfo struct { bufp int // location of next record in buf. } +// DevNull is the name of the operating system's ``null device.'' +// 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. // It returns the File and an Error, if any. diff --git a/src/pkg/os/file_windows.go b/src/pkg/os/file_windows.go index 4f7acbb08c..2c1c20ccc6 100644 --- a/src/pkg/os/file_windows.go +++ b/src/pkg/os/file_windows.go @@ -17,6 +17,8 @@ type dirInfo struct { usefirststat bool } +const DevNull = "NUL" + func (file *File) isdir() bool { return file != nil && file.dirinfo != nil } func openFile(name string, flag int, perm int) (file *File, err Error) { |
