Skip to content

Commit bbbc714

Browse files
Brett Schifftautschnig
authored andcommitted
Fix for handling of wchars on windows in getting the directory name
1 parent f061938 commit bbbc714

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/util/file_util.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Date: January 2012
5050
/// \return current working directory
5151
std::string get_current_working_directory()
5252
{
53-
#ifndef _WIN32
53+
#ifndef _WIN32
5454
errno=0;
5555
char *wd=realpath(".", nullptr);
5656

@@ -60,13 +60,19 @@ std::string get_current_working_directory()
6060

6161
std::string working_directory=wd;
6262
free(wd);
63-
#else
64-
char buffer[4096];
63+
#else
64+
TCHAR buffer[4096];
6565
DWORD retval=GetCurrentDirectory(4096, buffer);
6666
if(retval == 0)
6767
throw system_exceptiont("failed to get current directory of process");
68+
69+
# ifdef UNICODE
70+
std::string working_directory(narrow(buffer));
71+
# else
6872
std::string working_directory(buffer);
69-
#endif
73+
# endif
74+
75+
#endif
7076

7177
return working_directory;
7278
}

0 commit comments

Comments
 (0)