Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. char buffer[2048];
  2.  
  3. readlink("/proc/self/exe", buffer, 2048);
  4.  
  5. std::stringstream ss;
  6. ss << buffer;
  7. std::string exeFile = ss.str();
  8. std::string directory;
  9.  
  10. const size_t last_slash_idx = exeFile.rfind('/');
  11. if (std::string::npos != last_slash_idx)
  12. {
  13. directory = exeFile.substr(0, last_slash_idx);
  14. }
  15. return directory;
  16. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement