Is there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the
Here's code to get the full path to the executing app:
Windows:
int bytes = GetModuleFileName(NULL, pBuf, len); return bytes ? bytes : -1;
Linux:
int bytes = MIN(readlink("/proc/self/exe", pBuf, len), len - 1); if(bytes >= 0) pBuf[bytes] = '\0'; return bytes;