Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28a83ab commit de9775aCopy full SHA for de9775a
1 file changed
Python/getcwd.c
@@ -0,0 +1,35 @@
1
+/* Quick hack to get posix.getcwd() working for pure BSD 4.3 */
2
+
3
+#include "sys/param.h"
4
+#include "errno.h"
5
6
+extern int errno;
7
8
+extern char *getwd();
9
10
+char *
11
+getcwd(buf, size)
12
+ char *buf;
13
+ int size;
14
+{
15
+ char localbuf[MAXPATHLEN+1];
16
+ char *ret;
17
18
+ if (size <= 0) {
19
+ errno = EINVAL;
20
+ return NULL;
21
+ }
22
+ ret = getwd(localbuf);
23
+ if (ret != NULL && strlen(localbuf) >= size) {
24
+ errno = ERANGE;
25
26
27
+ if (ret == NULL) {
28
+ errno = EACCES; /* Most likely error */
29
30
31
+ strncpy(buf, localbuf, size);
32
+ return buf;
33
+}
34
35
+/* PS: for really old systems you must popen /bin/pwd ... */
0 commit comments