1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
char * getCurrProPath() {
char * buf = new char[1024];
int n;
n = readlink("/proc/self/exe", buf, 1024);
if (n < 0 || n > 1024){
printf("Cannot get current pro path!\n");
delete buf;
return NULL;
}
for (int i = n; i >=0; --i) {
if (buf[i] == '\') {
buf[i] = '\0';
break;
}
}
return buf;
}