| 72 | } |
| 73 | |
| 74 | TFsPath TFsPath::RelativeTo(const TFsPath& root) const { |
| 75 | TSplit split = GetSplit(); |
| 76 | const TSplit& rsplit = root.GetSplit(); |
| 77 | |
| 78 | if (split.Reconstruct() == rsplit.Reconstruct()) { |
| 79 | return TFsPath(); |
| 80 | } |
| 81 | |
| 82 | if (!this->IsSubpathOf(root)) { |
| 83 | ythrow TIoException() << "path " << *this << " is not subpath of " << root; |
| 84 | } |
| 85 | |
| 86 | split.erase(split.begin(), split.begin() + rsplit.size()); |
| 87 | split.IsAbsolute = false; |
| 88 | |
| 89 | return TFsPath(split.Reconstruct()); |
| 90 | } |
| 91 | |
| 92 | TFsPath TFsPath::RelativePath(const TFsPath& root) const { |
| 93 | TSplit split = GetSplit(); |
no test coverage detected