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

Method replacePropertyFiles

src/App/ProjectFile.cpp:813–853  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

811}
812
813std::string ProjectFile::replacePropertyFiles(const std::map<std::string, App::Property*>& props)
814{
815 // create a new zip file with the name '<zipfile>.<uuid>'
816 std::string uuid = Base::Uuid::createUuid();
817 std::string fn = stdFile;
818 fn += ".";
819 fn += uuid;
820 Base::FileInfo tmp(fn);
821 Base::ofstream newZip(tmp, std::ios::out | std::ios::binary);
822
823 // open extra scope
824 {
825 // standard compression
826 const int compressionLevel = 6;
827 Base::ZipWriter writer(newZip);
828 writer.setComment("FreeCAD Document");
829 writer.setLevel(compressionLevel);
830
831 // open the original zip file
832 zipios::ZipFile project(stdFile);
833 zipios::ConstEntries files = project.entries();
834 for (const auto& it : files) {
835 std::string file = it->getFileName();
836 writer.putNextEntry(file.c_str());
837
838 auto jt = props.find(file);
839 if (jt != props.end()) {
840 jt->second->SaveDocFile(writer);
841 }
842 else {
843 std::unique_ptr<std::istream> str(project.getInputStream(file));
844 if (str) {
845 *str >> writer.Stream().rdbuf();
846 }
847 }
848 }
849 project.close();
850 }
851
852 return fn;
853}
854
855bool ProjectFile::replaceProjectFile(const std::string& name, bool keepfile)
856{

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected