diff options
Diffstat (limited to 'tensorflow/core/platform/env.cc')
-rw-r--r-- | tensorflow/core/platform/env.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tensorflow/core/platform/env.cc b/tensorflow/core/platform/env.cc index 44f11aef96..12ef55ec26 100644 --- a/tensorflow/core/platform/env.cc +++ b/tensorflow/core/platform/env.cc @@ -22,6 +22,7 @@ limitations under the License. #endif #if defined(PLATFORM_WINDOWS) #include <windows.h> +#include "tensorflow/core/platform/windows/windows_file_system.h" #define PATH_MAX MAX_PATH #else #include <unistd.h> @@ -266,8 +267,11 @@ string Env::GetExecutablePath() { _NSGetExecutablePath(unresolved_path, &buffer_size); CHECK(realpath(unresolved_path, exe_path)); #elif defined(PLATFORM_WINDOWS) - HMODULE hModule = GetModuleHandle(NULL); - GetModuleFileName(hModule, exe_path, MAX_PATH); + HMODULE hModule = GetModuleHandleW(NULL); + WCHAR wc_file_path[MAX_PATH] = {0}; + GetModuleFileNameW(hModule, wc_file_path, MAX_PATH); + string file_path = WindowsFileSystem::WideCharToUtf8(wc_file_path); + std::copy(file_path.begin(), file_path.end(), exe_path); #else CHECK_NE(-1, readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1)); #endif |