log/windows: Use _wfreopen and _wrename where needed (bug #22897)
Instead of the ANSI-only freopen() and rename(). This should fix the bug for real this time. Thanks to gfgtdf for testing and suggesting the fix.
This commit is contained in:
parent
044a6a999d
commit
c9c975e256
3 changed files with 20 additions and 2 deletions
|
@ -1,6 +1,11 @@
|
|||
Version 1.13.2+dev:
|
||||
* Language and i18n:
|
||||
* Updated translations:
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fix the new log code on Windows to actually use Unicode-aware functions
|
||||
in a couple of places so Wesnoth does not quit on startup when trying to
|
||||
relocate the log file to a path with Unicode characters (bug #22897,
|
||||
definitely fixed this time).
|
||||
|
||||
Version 1.13.2:
|
||||
* Add-ons client:
|
||||
|
|
|
@ -6,6 +6,12 @@ Version 1.13.2+dev:
|
|||
* Language and i18n:
|
||||
* Updated translations:
|
||||
|
||||
* Miscellaneous and bug fixes:
|
||||
* Fix the new log code on Windows to actually use Unicode-aware functions
|
||||
in a couple of places so Wesnoth does not quit on startup when trying to
|
||||
relocate the log file to a path with Unicode characters (bug #22897,
|
||||
definitely fixed this time).
|
||||
|
||||
|
||||
Version 1.13.2:
|
||||
* Campaigns:
|
||||
|
|
|
@ -338,7 +338,12 @@ void log_file_manager::move_log_file(const std::string& log_dir)
|
|||
// cur_path_ with NUL, hence the backup above.
|
||||
open_log_file("NUL", false);
|
||||
|
||||
if(rename(old_path.c_str(), new_path.c_str()) != 0) {
|
||||
const std::wstring old_path_w
|
||||
= unicode_cast<std::wstring>(old_path);
|
||||
const std::wstring new_path_w
|
||||
= unicode_cast<std::wstring>(new_path);
|
||||
|
||||
if(_wrename(old_path_w.c_str(), new_path_w.c_str()) != 0) {
|
||||
throw libc_error();
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +377,9 @@ void log_file_manager::do_redirect_single_stream(const std::string& file_path,
|
|||
fflush(crts);
|
||||
cxxs.flush();
|
||||
|
||||
if(!freopen(file_path.c_str(), (truncate ? "w" : "a"), crts))
|
||||
const std::wstring file_path_w = unicode_cast<std::wstring>(file_path);
|
||||
|
||||
if(!_wfreopen(file_path_w.c_str(), (truncate ? L"w" : L"a"), crts))
|
||||
{
|
||||
throw libc_error();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue