"This patch implements the method with the GetModuleFileName function for windows."
authorChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 05:38:04 +0000 (05:38 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 15 Jun 2009 05:38:04 +0000 (05:38 +0000)
Patch by Benjamin Kramer!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73379 91177308-0d34-0410-b5e6-96231b3b80d8

lib/System/Win32/Path.inc

index 62da3a34c4501aba9078f48123914d71798fcce1..683c94bba44eea5a40303ba549a8095c197fb787 100644 (file)
@@ -248,7 +248,9 @@ Path::GetCurrentDirectory() {
 /// GetMainExecutable - Return the path to the main executable, given the
 /// value of argv[0] from program startup.
 Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
-  return Path();
+  char pathname[MAX_PATH];
+  DWORD ret = ::GetModuleFileNameA(NULL, pathname, MAX_PATH);
+  return ret != MAX_PATH ? Path(pathname) : Path();
 }