Blame

21d68c Bob Green 2026-08-26 11:45:12
1
% getcwd(3) Version 1.0 | Library Functions Manual
2
***
3
4
## NAME
5
6
**getcwd** — get current working directory.
7
8
### LIBRARY
9
10
libmega C library (-lmega)
11
12
### SYNOPSIS
13
14
```
15
#include <unistd.h>
16
17
char *getcwd(char *buf, size_t size);
18
```
19
20
### DESCRIPTION
21
**getcwd()** copies the absolute pathname of the current working directory to the array pointed to by **_buf_**, which is of **_length_** size.
22
23
**getwd()** does not malloc(3) any memory. The **_buf_** argument should be a pointer to an array at least **PATH_MAX** bytes long. If the length of the absolute pathname of the current working directory, including the terminating null byte, exceeds **PATH_MAX** bytes, **NULL** is returned, and **_errno_** is set to **ENAMETOOLONG**.
24
25
### RETURN VALUE
26
27
28
### ERRORS
29
**getcwd()** can fail with the following errors:
30
31
* ENAMETOOLONG - The size of the null-terminated absolute pathname string exceeds **PATH_MAX** bytes.
32
* ERANGE - The **_size_** argument is less than the length of the absolute pathname of the working directory, including the terminating null byte. You need to allocate a bigger array and try again.
33
34
### NOTES
35
36
None.
37
38
### BUGS
39
40
See GitHub Issues: <https://github.com/znac049/mega-micros-sbc3/issues>
41
42
### AUTHOR
43
44
Bob Green <bob@chippers.org.uk>
45
46
### SEE ALSO
47
48
**chdir(2), open(2), unlink(2)