Reworked the rename_file() function on Windows to work reliably and

atomically. The code was taken from the llvm project, it is complex
and hopefully it covers all the Windows file system quirks. Vojtech
has highest hopes, that this will fix the various PrusaSlicer.ini
file corruptions.

Enabled the locales switching and error handling on Linux as well,
where now the missing locales are reported and running the locale-gen
tool is recommended.
This commit is contained in:
bubnikv 2019-08-20 16:19:30 +02:00
parent a83da0f72c
commit fd3fe75d1c
6 changed files with 248 additions and 62 deletions
src/libslic3r

View file

@ -607,7 +607,7 @@ void GCode::do_export(Print *print, const char *path, GCodePreviewData *preview_
m_analyzer.reset();
}
if (rename_file(path_tmp, path) != 0)
if (rename_file(path_tmp, path))
throw std::runtime_error(
std::string("Failed to rename the output G-code file from ") + path_tmp + " to " + path + '\n' +
"Is " + path_tmp + " locked?" + '\n');