| 452 | } |
| 453 | |
| 454 | void PropertyFileIncluded::RestoreDocFile(Base::Reader& reader) |
| 455 | { |
| 456 | Base::FileInfo fi(_cValue.c_str()); |
| 457 | if (fi.exists() && !fi.isWritable()) { |
| 458 | // This happens when an object is being restored and tries to reference the |
| 459 | // same file of another object (e.g. for copy&paste of objects inside the same document). |
| 460 | return; |
| 461 | } |
| 462 | Base::ofstream to(fi, std::ios::out | std::ios::binary); |
| 463 | if (!to) { |
| 464 | std::stringstream str; |
| 465 | str << "PropertyFileIncluded::RestoreDocFile(): " |
| 466 | << "File '" << _cValue << "' in transient directory cannot be created."; |
| 467 | throw Base::FileSystemError(str.str()); |
| 468 | } |
| 469 | |
| 470 | // copy plain data |
| 471 | aboutToSetValue(); |
| 472 | unsigned char c; |
| 473 | while (reader.get((char&)c)) { |
| 474 | to.put((char)c); |
| 475 | } |
| 476 | to.close(); |
| 477 | |
| 478 | // set read-only after restoring the file |
| 479 | fi.setPermissions(Base::FileInfo::ReadOnly); |
| 480 | hasSetValue(); |
| 481 | } |
| 482 | |
| 483 | Property* PropertyFileIncluded::Copy() const |
| 484 | { |
nothing calls this directly
no test coverage detected