MCPcopy Create free account
hub / github.com/catboost/catboost / LinkTo

Method LinkTo

util/system/file.cpp:658–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
659#if defined(_unix_)
660 while (dup2(fh.Fd_, Fd_) == -1) {
661 if (errno != EINTR) {
662 return false;
663 }
664 }
665 return true;
666#elif defined(_win_)
667 TFileHandle nh(fh.Duplicate());
668
669 if (!nh.IsOpen()) {
670 return false;
671 }
672
673 // not thread-safe
674 nh.Swap(*const_cast<TFileHandle*>(this));
675
676 return true;
677#else
678 #error unsupported
679#endif
680}
681
682int TFileHandle::Flock(int op) noexcept {
683 return ::Flock(Fd_, op);

Callers 4

ReopenLogMethod · 0.80
ReopenLogMethod · 0.80
TestLinkToMethod · 0.80
OnForkMethod · 0.80

Calls 6

dup2Function · 0.50
DuplicateMethod · 0.45
IsOpenMethod · 0.45
SwapMethod · 0.45
GetHandleMethod · 0.45
GetNameMethod · 0.45

Tested by 1

TestLinkToMethod · 0.64