mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +00:00
c7a23183e8
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.
28 lines
516 B
Go
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
|