MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / replaceInputFile

Method replaceInputFile

src/App/ProjectFile.cpp:731–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731std::string ProjectFile::replaceInputFile(const std::string& name, std::istream& inp)
732{
733 // create a new zip file with the name '<zipfile>.<uuid>'
734 std::string uuid = Base::Uuid::createUuid();
735 std::string fn = stdFile;
736 fn += ".";
737 fn += uuid;
738 Base::FileInfo tmp(fn);
739 Base::ofstream newZip(tmp, std::ios::out | std::ios::binary);
740
741 // standard compression
742 const int compressionLevel = 6;
743 zipios::ZipOutputStream outZip(newZip);
744 outZip.setComment("FreeCAD Document");
745 outZip.setLevel(compressionLevel);
746
747 // open the original zip file
748 zipios::ZipFile project(stdFile);
749 zipios::ConstEntries files = project.entries();
750 for (const auto& it : files) {
751 std::string file = it->getFileName();
752 outZip.putNextEntry(file);
753 if (file == name) {
754 inp >> outZip.rdbuf();
755 }
756 else {
757 std::unique_ptr<std::istream> str(project.getInputStream(file));
758 if (str) {
759 *str >> outZip.rdbuf();
760 }
761 }
762 }
763
764 project.close();
765 outZip.close();
766 newZip.close();
767
768 return fn;
769}
770
771std::string ProjectFile::replaceInputFiles(const std::map<std::string, std::istream*>& inp)
772{

Callers

nothing calls this directly

Calls 7

setCommentMethod · 0.45
setLevelMethod · 0.45
entriesMethod · 0.45
getFileNameMethod · 0.45
putNextEntryMethod · 0.45
getInputStreamMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected