Skip to content

Commit

Permalink
Windows: use Win32 API to obtain executable name.
Browse files Browse the repository at this point in the history
cygwin lies about it, stripping the '.exe' suffix.

Needed for #276.

--
MOS_MIGRATED_REVID=114860126
  • Loading branch information
dslomov authored and kchodorow committed Feb 17, 2016
1 parent 806d9c6 commit 3157412
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/main/cpp/blaze_util_mingw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,9 @@ void WarnFilesystemType(const string& output_base) {

string GetSelfPath() {
char buffer[PATH_MAX] = {};
ssize_t bytes = readlink("/proc/self/exe", buffer, sizeof(buffer));
if (bytes == sizeof(buffer)) {
// symlink contents truncated
bytes = -1;
errno = ENAMETOOLONG;
if (!GetModuleFileName(0, buffer, sizeof(buffer))) {
pdie(255, "Error %u getting executable file name\n", GetLastError());
}
if (bytes == -1) {
pdie(blaze_exit_code::INTERNAL_ERROR, "error reading /proc/self/exe");
}
buffer[bytes] = '\0'; // readlink does not NUL-terminate
return string(buffer);
}

Expand Down

0 comments on commit 3157412

Please sign in to comment.