You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
269 B

#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <unistd.h>
char *get_current_dir_name(void) {
char buf[PATH_MAX];
char* res = getenv("PWD");
if(res && *res) return strdup(res);
if(!getcwd(buf, sizeof(buf))) return NULL;
return strdup(buf);
}