blob: 212edf3169143b0196dce39bad562753c7b6acc1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
#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);
}
|