Ported PrintConfigBase::_handle_legacy from Perl to C++,

merged from upstream Slic3r, thanks to @alexrj.
This commit is contained in:
bubnikv 2017-09-18 09:56:48 +02:00
parent cd084a33c6
commit e16f827223
6 changed files with 116 additions and 95 deletions

View file

@ -385,21 +385,17 @@ void ConfigBase::load_from_gcode(const std::string &file)
void ConfigBase::save(const std::string &file) const
{
using namespace std;
boost::nowide::ofstream c;
c.open(file, ios::out | ios::trunc);
c.open(file, std::ios::out | std::ios::trunc);
{
time_t now;
std::time_t now;
time(&now);
char buf[sizeof "0000-00-00 00:00:00"];
strftime(buf, sizeof buf, "%F %T", gmtime(&now));
c << "# generated by Slic3r " << SLIC3R_VERSION << " on " << buf << endl;
strftime(buf, sizeof(buf), "%F %T", gmtime(&now));
c << "# generated by Slic3r " << SLIC3R_VERSION << " on " << buf << std::endl;
}
t_config_option_keys my_keys = this->keys();
for (t_config_option_keys::const_iterator opt_key = my_keys.begin(); opt_key != my_keys.end(); ++opt_key)
c << *opt_key << " = " << this->serialize(*opt_key) << endl;
for (const std::string &opt_key : this->keys())
c << opt_key << " = " << this->serialize(opt_key) << std::endl;
c.close();
}