| 729 | } |
| 730 | |
| 731 | std::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 | |
| 771 | std::string ProjectFile::replaceInputFiles(const std::map<std::string, std::istream*>& inp) |
| 772 | { |
nothing calls this directly
no test coverage detected