file_hosted.mx raw

   1  //go:build ignore
   2  
   3  // This file assumes there is a libc available that runs on a real operating
   4  // system.
   5  
   6  package syscall
   7  
   8  const pathMax = 1024
   9  
  10  func Getwd() (string, error) {
  11  	var buf [pathMax]byte
  12  	s := libc_getcwd(&buf[0], uint(len(buf)))
  13  	if s == nil {
  14  		return "", getErrno()
  15  	}
  16  	n := clen(buf[:])
  17  	if n < 1 {
  18  		return "", EINVAL
  19  	}
  20  	return string(buf[:n]), nil
  21  }
  22  
  23  // char *getcwd(char *buf, size_t size)
  24  //
  25  //export getcwd
  26  func libc_getcwd(buf *byte, size uint) *byte
  27