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

Method Copy

src/App/PropertyFile.cpp:483–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483Property* PropertyFileIncluded::Copy() const
484{
485 std::unique_ptr<PropertyFileIncluded> prop(new PropertyFileIncluded());
486
487 // remember the base name
488 prop->_BaseFileName = _BaseFileName;
489
490 Base::FileInfo file(_cValue);
491 if (file.exists()) {
492 // create a new name in the document transient directory
493 Base::FileInfo newName(getUniqueFileName(file.dirPath(), file.fileName()));
494 if (this->StatusBits.test(10)) {
495 // rename the file
496 bool done = file.renameFile(newName.filePath().c_str());
497 if (!done) {
498 std::stringstream str;
499 str << "PropertyFileIncluded::Copy(): "
500 << "Renaming the file '" << file.filePath() << "' to '" << newName.filePath()
501 << "' failed.";
502 throw Base::FileSystemError(str.str());
503 }
504 }
505 else {
506 // copy the file
507 bool done = file.copyTo(newName.filePath().c_str());
508 if (!done) {
509 std::stringstream str;
510 str << "PropertyFileIncluded::Copy(): "
511 << "Copying the file '" << file.filePath() << "' to '" << newName.filePath()
512 << "' failed.";
513 throw Base::FileSystemError(str.str());
514 }
515 }
516
517 // remember the new name for the Undo
518 Base::Console().log("Copy '%s' to '%s'\n", _cValue.c_str(), newName.filePath().c_str());
519 prop->_cValue = newName.filePath().c_str();
520
521 // make backup files writable to avoid copying them again on undo/redo
522 newName.setPermissions(Base::FileInfo::ReadWrite);
523 }
524
525 return prop.release();
526}
527
528void PropertyFileIncluded::Paste(const Property& from)
529{

Callers

nothing calls this directly

Calls 13

FileSystemErrorFunction · 0.85
dirPathMethod · 0.80
renameFileMethod · 0.80
setPermissionsMethod · 0.80
existsMethod · 0.45
fileNameMethod · 0.45
testMethod · 0.45
c_strMethod · 0.45
filePathMethod · 0.45
strMethod · 0.45
copyToMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected