Initial revision

This commit is contained in:
Guido van Rossum 1991-01-21 14:27:52 +00:00
parent 28a83ab393
commit de9775af8f
1 changed files with 35 additions and 0 deletions

35
Python/getcwd.c Normal file
View File

@ -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 ... */