github.com/aykevl/tinygo@v0.5.0/src/os/file.go (about)

     1  // Package os implements a subset of the Go "os" package. See
     2  // https://godoc.org/os for details.
     3  //
     4  // Note that the current implementation is blocking. This limitation should be
     5  // removed in a future version.
     6  package os
     7  
     8  import (
     9  	"errors"
    10  )
    11  
    12  // Portable analogs of some common system call errors.
    13  var (
    14  	ErrUnsupported = errors.New("operation not supported")
    15  )
    16  
    17  // Stdin, Stdout, and Stderr are open Files pointing to the standard input,
    18  // standard output, and standard error file descriptors.
    19  var (
    20  	Stdin  = &File{0, "/dev/stdin"}
    21  	Stdout = &File{1, "/dev/stdout"}
    22  	Stderr = &File{2, "/dev/stderr"}
    23  )
    24  
    25  // File represents an open file descriptor.
    26  type File struct {
    27  	fd   uintptr
    28  	name string
    29  }
    30  
    31  // NewFile returns a new File with the given file descriptor and name.
    32  func NewFile(fd uintptr, name string) *File {
    33  	return &File{fd, name}
    34  }
    35  
    36  // Fd returns the integer Unix file descriptor referencing the open file. The
    37  // file descriptor is valid only until f.Close is called.
    38  func (f *File) Fd() uintptr {
    39  	return f.fd
    40  }