| 769 | } |
| 770 | |
| 771 | std::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 | |
| 813 | std::string ProjectFile::replacePropertyFiles(const std::map<std::string, App::Property*>& props) |
| 814 | { |
nothing calls this directly
no test coverage detected