]> Cypherpunks repositories - gostls13.git/commitdiff
os: Null device
authorPeter Mundy <go.peter.90@gmail.com>
Tue, 3 Aug 2010 20:03:50 +0000 (13:03 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 3 Aug 2010 20:03:50 +0000 (13:03 -0700)
R=rsc, cw
CC=golang-dev
https://golang.org/cl/1854042

src/pkg/exec/exec.go
src/pkg/os/file_unix.go
src/pkg/os/file_windows.go

index ee3cec686ba233296c3599930a1e00250fc4cec5..e1c49004f713d88e3757344de98a8d2023604db0 100644 (file)
@@ -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 {
index 6cf26614066ed6bc225bcb9099cf44d71b36c0d8..76033c3e39599f61a65288849ab0f93f2ec2ce26 100644 (file)
@@ -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.
index 4f7acbb08ce241624d1fac0bf51f8fb571cebf46..2c1c20ccc617a5161a61fef41f13ca92dca0559f 100644 (file)
@@ -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) {