Files
tinygo/src/syscall/file_hosted.go
T
Ayke van Laethem c7a23183e8 all: format code according to Go 1.19 rules
Go 1.19 started reformatting code in a way that makes it more obvious
how it will be rendered on pkg.go.dev. It gets it almost right, but not
entirely. Therefore, I had to modify some of the comments so that they
are formatted correctly.
2022-08-04 12:18:32 +02:00

28 lines
516 B
Go

//go:build !baremetal && !wasm
// +build !baremetal,!wasm
// This file assumes there is a libc available that runs on a real operating
// system.
package syscall
const pathMax = 1024
func Getwd() (string, error) {
var buf [pathMax]byte
s := libc_getcwd(&buf[0], uint(len(buf)))
if s == nil {
return "", getErrno()
}
n := clen(buf[:])
if n < 1 {
return "", EINVAL
}
return string(buf[:n]), nil
}
// char *getcwd(char *buf, size_t size)
//
//export getcwd
func libc_getcwd(buf *byte, size uint) *byte