summaryrefslogtreecommitdiffstats
path: root/Python/getcwd.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-01-21 14:27:52 (GMT)
committerGuido van Rossum <guido@python.org>1991-01-21 14:27:52 (GMT)
commitde9775af8fc6f2e976f3815f00a5f389c777a91f (patch)
treeadce417efd4d2c5d3fcbd8d68770201653b1528a /Python/getcwd.c
parent28a83ab393740e92b94f63a24ab95e132150f2c9 (diff)
downloadcpython-de9775af8fc6f2e976f3815f00a5f389c777a91f.zip
cpython-de9775af8fc6f2e976f3815f00a5f389c777a91f.tar.gz
cpython-de9775af8fc6f2e976f3815f00a5f389c777a91f.tar.bz2
Initial revision
Diffstat (limited to 'Python/getcwd.c')
-rw-r--r--Python/getcwd.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/Python/getcwd.c b/Python/getcwd.c
new file mode 100644
index 0000000..340acab
--- /dev/null
+++ b/Python/getcwd.c
@@ -0,0 +1,35 @@
+/* Quick hack to get posix.getcwd() working for pure BSD 4.3 */
+
+#include "sys/param.h"
+#include "errno.h"
+
+extern int errno;
+
+extern char *getwd();
+
+char *
+getcwd(buf, size)
+ char *buf;
+ int size;
+{
+ char localbuf[MAXPATHLEN+1];
+ char *ret;
+
+ if (size <= 0) {
+ errno = EINVAL;
+ return NULL;
+ }
+ ret = getwd(localbuf);
+ if (ret != NULL && strlen(localbuf) >= size) {
+ errno = ERANGE;
+ return NULL;
+ }
+ if (ret == NULL) {
+ errno = EACCES; /* Most likely error */
+ return NULL;
+ }
+ strncpy(buf, localbuf, size);
+ return buf;
+}
+
+/* PS: for really old systems you must popen /bin/pwd ... */