| 811 | } |
| 812 | |
| 813 | std::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 | |
| 855 | bool ProjectFile::replaceProjectFile(const std::string& name, bool keepfile) |
| 856 | { |
nothing calls this directly
no test coverage detected