| 481 | } |
| 482 | |
| 483 | Property* 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 | |
| 528 | void PropertyFileIncluded::Paste(const Property& from) |
| 529 | { |
nothing calls this directly
no test coverage detected