UI: Fix creation of log files with non-english paths

This commit fixes creating log files in windows with Unicode profile
names.

I encountered this bug when running obs-studio 18.0.2 in Windows 8.1 x64
with my user profile path containing Unicode characters.

Steps to reproduce:

1) Create a windows user with a Unicode name: "пользователь"
2) Run OBS Studio, go to Help -> Log Files -> View current log (Nothing
happens)

The expected result is opening current log file.

Closes jp9000/obs-studio#916
This commit is contained in:
Igor Bochkariov 2017-05-15 14:38:24 +04:00 committed by jp9000
parent 59fcfaadb5
commit 6e1c4caf99

View file

@ -1223,8 +1223,16 @@ static void create_log_file(fstream &logFile)
dst << "obs-studio/logs/" << currentLogFile.c_str();
BPtr<char> path(GetConfigPathPtr(dst.str().c_str()));
#ifdef _WIN32
BPtr<wchar_t> wpath;
os_utf8_to_wcs_ptr(path, 0, &wpath);
logFile.open(wpath,
ios_base::in | ios_base::out | ios_base::trunc);
#else
logFile.open(path,
ios_base::in | ios_base::out | ios_base::trunc);
#endif
if (logFile.is_open()) {
delete_oldest_file("obs-studio/logs");