Browse Source

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
Igor Bochkariov 8 years ago
parent
commit
6e1c4caf99
1 changed files with 8 additions and 0 deletions
  1. 8 0
      UI/obs-app.cpp

+ 8 - 0
UI/obs-app.cpp

@@ -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");