File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,11 @@ namespace xtl
4949 inline std::string executable_path ()
5050 {
5151 std::string path;
52- char buffer[1024 ];
52+ #if defined(UNICODE)
53+ wchar_t buffer[1024 ];
54+ #else
55+ char buffer[1024 ];
56+ #endif
5357 std::memset (buffer, ' \0 ' , sizeof (buffer));
5458#if defined(__linux__)
5559 if (readlink (" /proc/self/exe" , buffer, sizeof (buffer)) != -1 )
@@ -61,14 +65,21 @@ namespace xtl
6165 // failed to determine run path
6266 }
6367#elif defined (_WIN32)
64- if (GetModuleFileName (nullptr , buffer, sizeof (buffer)) != 0 )
68+ #if defined(UNICODE)
69+ if (GetModuleFileNameW (nullptr , buffer, sizeof (buffer)) != 0 )
6570 {
66- path = buffer;
71+ // Convert wchar_t to std::string
72+ std::wstring wideString (buffer);
73+ std::string narrowString (wideString.begin (), wideString.end ());
74+ path = narrowString;
6775 }
68- else
76+ #else
77+ if (GetModuleFileNameA (nullptr , buffer, sizeof (buffer)) != 0 )
6978 {
70- // failed to determine run path
79+ path = buffer;
7180 }
81+ #endif
82+ // failed to determine run path
7283#elif defined (__APPLE__)
7384 std::uint32_t size = sizeof (buffer);
7485 if (_NSGetExecutablePath (buffer, &size) == 0 )
You can’t perform that action at this time.
0 commit comments