| 480 | } |
| 481 | |
| 482 | bool cmFileCopier::InstallSymlinkChain(std::string& fromFile, |
| 483 | std::string& toFile) |
| 484 | { |
| 485 | std::string newFromFile; |
| 486 | std::string toFilePath = cmSystemTools::GetFilenamePath(toFile); |
| 487 | while (cmSystemTools::ReadSymlink(fromFile, newFromFile)) { |
| 488 | if (!cmSystemTools::FileIsFullPath(newFromFile)) { |
| 489 | std::string fromFilePath = cmSystemTools::GetFilenamePath(fromFile); |
| 490 | newFromFile = cmStrCat(fromFilePath, '/', newFromFile); |
| 491 | } |
| 492 | |
| 493 | std::string symlinkTarget = cmSystemTools::GetFilenameName(newFromFile); |
| 494 | |
| 495 | bool copy = true; |
| 496 | if (!this->Always) { |
| 497 | std::string oldSymlinkTarget; |
| 498 | if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) { |
| 499 | if (symlinkTarget == oldSymlinkTarget) { |
| 500 | copy = false; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | this->ReportCopy(toFile, TypeLink, copy); |
| 506 | |
| 507 | if (copy) { |
| 508 | cmSystemTools::RemoveFile(toFile); |
| 509 | cmSystemTools::MakeDirectory(toFilePath); |
| 510 | |
| 511 | cmsys::Status status = |
| 512 | cmSystemTools::CreateSymlinkQuietly(symlinkTarget, toFile); |
| 513 | if (!status) { |
| 514 | std::string e = cmStrCat(this->Name, " cannot create symlink\n ", |
| 515 | toFile, "\nbecause: ", status.GetString()); |
| 516 | this->Status.SetError(e); |
| 517 | return false; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | fromFile = newFromFile; |
| 522 | toFile = cmStrCat(toFilePath, '/', symlinkTarget); |
| 523 | } |
| 524 | |
| 525 | return true; |
| 526 | } |
| 527 | |
| 528 | bool cmFileCopier::InstallSymlink(std::string const& fromFile, |
| 529 | std::string const& toFile) |
no test coverage detected