From 55c698feeff9b204b01f698aac413679f4b913c2 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 26 Jan 2021 12:19:35 +0100 Subject: [PATCH] WIP: Exporting 3MFs through a streaming interface. --- src/libslic3r/Format/3mf.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index d021f0f6d..16fb18c17 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -2301,10 +2301,13 @@ namespace Slic3r { } stream << "\n"; + + mz_zip_writer_staged_context context; + std::string buf = stream.str(); - std::string out = stream.str(); - - if (!mz_zip_writer_add_mem(&archive, MODEL_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) + if (!mz_zip_writer_add_staged_open(&archive, &context, MODEL_FILE.c_str(), buf.size(), nullptr, nullptr, 0, MZ_DEFAULT_COMPRESSION, nullptr, 0, nullptr, 0) || + !mz_zip_writer_add_staged_data(&archive, &context, buf.data(), buf.size()) || + !mz_zip_writer_add_staged_finish(&archive, &context)) { add_error("Unable to add model file to archive"); return false;