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

Method replaceInputFiles

src/App/ProjectFile.cpp:771–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769}
770
771std::string ProjectFile::replaceInputFiles(const std::map<std::string, std::istream*>& inp)
772{
773 // create a new zip file with the name '<zipfile>.<uuid>'
774 std::string uuid = Base::Uuid::createUuid();
775 std::string fn = stdFile;
776 fn += ".";
777 fn += uuid;
778 Base::FileInfo tmp(fn);
779 Base::ofstream newZip(tmp, std::ios::out | std::ios::binary);
780
781 // standard compression
782 const int compressionLevel = 6;
783 zipios::ZipOutputStream outZip(newZip);
784 outZip.setComment("FreeCAD Document");
785 outZip.setLevel(compressionLevel);
786
787 // open the original zip file
788 zipios::ZipFile project(stdFile);
789 zipios::ConstEntries files = project.entries();
790 for (const auto& it : files) {
791 std::string file = it->getFileName();
792 outZip.putNextEntry(file);
793
794 auto jt = inp.find(file);
795 if (jt != inp.end()) {
796 *jt->second >> outZip.rdbuf();
797 }
798 else {
799 std::unique_ptr<std::istream> str(project.getInputStream(file));
800 if (str) {
801 *str >> outZip.rdbuf();
802 }
803 }
804 }
805
806 project.close();
807 outZip.close();
808 newZip.close();
809
810 return fn;
811}
812
813std::string ProjectFile::replacePropertyFiles(const std::map<std::string, App::Property*>& props)
814{

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected