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

     1  // +build darwin linux,!avr,!cortexm
     2  
     3  package os
     4  
     5  import (
     6  	"syscall"
     7  )
     8  
     9  // Read reads up to len(b) bytes from the File. It returns the number of bytes
    10  // read and any error encountered. At end of file, Read returns 0, io.EOF.
    11  func (f *File) Read(b []byte) (n int, err error) {
    12  	return syscall.Read(int(f.fd), b)
    13  }
    14  
    15  // Write writes len(b) bytes to the File. It returns the number of bytes written
    16  // and an error, if any. Write returns a non-nil error when n != len(b).
    17  func (f *File) Write(b []byte) (n int, err error) {
    18  	return syscall.Write(int(f.fd), b)
    19  }
    20  
    21  // Close closes the File, rendering it unusable for I/O.
    22  func (f *File) Close() error {
    23  	return syscall.Close(int(f.fd))
    24  }