Initial implementation of configuration snapshotting.

This commit is contained in:
bubnikv 2018-04-06 16:49:33 +02:00
parent 2b8da333ef
commit 670061ac33
11 changed files with 787 additions and 31 deletions

View file

@ -263,7 +263,6 @@ namespace PerlUtils {
std::string timestamp_str()
{
const auto now = boost::posix_time::second_clock::local_time();
const auto date = now.date();
char buf[2048];
sprintf(buf, "on %04d-%02d-%02d at %02d:%02d:%02d",
// Local date in an ANSII format.
@ -272,31 +271,4 @@ std::string timestamp_str()
return buf;
}
std::string octoprint_encode_file_send_request_content(const char *cpath, bool select, bool print, const char *boundary)
{
// Read the complete G-code string into a string buffer.
// It will throw if the file cannot be open or read.
std::stringstream str_stream;
{
boost::nowide::ifstream ifs(cpath);
str_stream << ifs.rdbuf();
}
boost::filesystem::path path(cpath);
std::string request = boundary + '\n';
request += "Content-Disposition: form-data; name=\"";
request += path.stem().string() + "\"; filename=\"" + path.filename().string() + "\"\n";
request += "Content-Type: application/octet-stream\n\n";
request += str_stream.str();
request += boundary + '\n';
request += "Content-Disposition: form-data; name=\"select\"\n\n";
request += select ? "true\n" : "false\n";
request += boundary + '\n';
request += "Content-Disposition: form-data; name=\"print\"\n\n";
request += print ? "true\n" : "false\n";
request += boundary + '\n';
return request;
}
}; // namespace Slic3r