| 152 | } |
| 153 | |
| 154 | TString TFsPath::GetName() const { |
| 155 | if (!IsDefined()) { |
| 156 | return TString(); |
| 157 | } |
| 158 | |
| 159 | const TSplit& split = GetSplit(); |
| 160 | |
| 161 | if (split.size() > 0) { |
| 162 | if (split.back() != "..") { |
| 163 | return TString(split.back()); |
| 164 | } else { |
| 165 | // cannot just drop last component, because path itself may be a symlink |
| 166 | return RealPath().GetName(); |
| 167 | } |
| 168 | } else { |
| 169 | if (split.IsAbsolute) { |
| 170 | return split.Reconstruct(); |
| 171 | } else { |
| 172 | return Cwd().GetName(); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | TString TFsPath::GetExtension() const { |
| 178 | return TString(GetSplit().Extension()); |