aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syscall/file_hosted.go
blob: 86fc62c408635e3956267f8046f0b53ce296f128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//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