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; }
|