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

Method Save

src/App/PropertyFile.cpp:356–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

354}
355
356void PropertyFileIncluded::Save(Base::Writer& writer) const
357{
358 // when saving a document under a new file name the transient directory
359 // name changes and thus the stored file name doesn't work any more.
360 if (!_cValue.empty() && !Base::FileInfo(_cValue).exists()) {
361 Base::FileInfo fi(getDocTransientPath() + "/" + _BaseFileName);
362 if (fi.exists()) {
363 _cValue = fi.filePath();
364 }
365 }
366
367 if (writer.isForceXML()) {
368 if (!_cValue.empty()) {
369 Base::FileInfo file(_cValue.c_str());
370 writer.Stream() << writer.ind() << "<FileIncluded data=\"" << file.fileName() << "\">"
371 << std::endl;
372 // write the file in the XML stream
373 writer.incInd();
374 writer.insertBinFile(_cValue.c_str());
375 writer.decInd();
376 writer.Stream() << writer.ind() << "</FileIncluded>" << endl;
377 }
378 else {
379 writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>" << std::endl;
380 }
381 }
382 else {
383 // instead initiate an extra file
384 if (!_cValue.empty()) {
385 Base::FileInfo file(_cValue.c_str());
386 std::string filename = writer.addFile(file.fileName().c_str(), this);
387 filename = encodeAttribute(filename);
388 writer.Stream() << writer.ind() << "<FileIncluded file=\"" << filename << "\"/>"
389 << std::endl;
390 }
391 else {
392 writer.Stream() << writer.ind() << "<FileIncluded file=\"\"/>" << std::endl;
393 }
394 }
395}
396
397void PropertyFileIncluded::Restore(Base::XMLReader& reader)
398{

Callers

nothing calls this directly

Calls 11

isForceXMLMethod · 0.80
incIndMethod · 0.80
insertBinFileMethod · 0.80
decIndMethod · 0.80
FileInfoClass · 0.50
emptyMethod · 0.45
existsMethod · 0.45
filePathMethod · 0.45
c_strMethod · 0.45
fileNameMethod · 0.45
addFileMethod · 0.45

Tested by

no test coverage detected