Implementation of realpath in FreeBSD (version 9.0 and less) and GetFullPathName in Windows did not require last component of the file name to exist (other implementations will fail if it does not). Use RealLocation if that behaviour is required.
| 437 | // did not require last component of the file name to exist (other implementations will fail |
| 438 | // if it does not). Use RealLocation if that behaviour is required. |
| 439 | TString RealPath(const TString& path) { |
| 440 | TTempBuf result; |
| 441 | Y_ASSERT(result.Size() > MAX_PATH); // TMP_BUF_LEN > MAX_PATH |
| 442 | #ifdef _win_ |
| 443 | if (GetFullPathName(path.data(), result.Size(), result.Data(), nullptr) == 0) |
| 444 | #else |
| 445 | if (realpath(path.data(), result.Data()) == nullptr) |
| 446 | #endif |
| 447 | ythrow TFileError() << "RealPath failed \"" << path << "\""; |
| 448 | return result.Data(); |
| 449 | } |
| 450 | |
| 451 | TString RealLocation(const TString& path) { |
| 452 | if (NFs::Exists(path)) { |
no test coverage detected