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

View file

@ -66,7 +66,12 @@ int CLI::run(int argc, char **argv)
boost::nowide::nowide_filesystem();
} catch (const std::runtime_error& ex) {
std::string caption = std::string(SLIC3R_APP_NAME) + " Error";
std::string text = std::string("An error occured while setting up locale.\n") + SLIC3R_APP_NAME + " will now terminate.\n\n" + ex.what();
std::string text = std::string("An error occured while setting up locale.\n") + (
#if !defined(_WIN32) && !defined(__APPLE__)
// likely some linux system
"You may need to reconfigure the missing locales, likely by running the \"locale-gen\"" and \"dpkg-reconfigure locales\" commands.\n"
#endif
SLIC3R_APP_NAME " will now terminate.\n\n") + ex.what();
#ifdef SLIC3R_GUI
if (m_actions.empty())
MessageBoxA(NULL, text.c_str(), caption.c_str(), MB_OK | MB_ICONERROR);
@ -426,7 +431,7 @@ int CLI::run(int argc, char **argv)
outfile_final = sla_print.print_statistics().finalize_output_path(outfile);
sla_print.export_raster(outfile_final);
}
if (outfile != outfile_final && Slic3r::rename_file(outfile, outfile_final) != 0) {
if (outfile != outfile_final && Slic3r::rename_file(outfile, outfile_final)) {
boost::nowide::cerr << "Renaming file " << outfile << " to " << outfile_final << " failed" << std::endl;
return 1;
}