Created
February 25, 2018 20:56
-
-
Save koreus7/de662c69a8c70a2b4fd97d3f9bbdaac3 to your computer and use it in GitHub Desktop.
Find PWD on OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mach-o/dyld.h> | |
unsigned int bufferSize = 512; | |
std::vector<char> buffer(bufferSize + 1); | |
if(_NSGetExecutablePath(&buffer[0], &bufferSize)) | |
{ | |
buffer.resize(bufferSize); | |
_NSGetExecutablePath(&buffer[0], &bufferSize); | |
} | |
std::string s = &buffer[0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment