| 203 | #endif |
| 204 | |
| 205 | cm::optional<std::string> ImplBase::ReadSymlink(std::string const& path, |
| 206 | cmsys::Status& status) |
| 207 | { |
| 208 | cm::optional<std::string> result; |
| 209 | std::string target; |
| 210 | status = this->OS.ReadSymlink(path, target); |
| 211 | if (status && ++this->SymlinkDepth >= MAX_SYMBOLIC_LINKS) { |
| 212 | status = cmsys::Status::POSIX(ELOOP); |
| 213 | } |
| 214 | if (status) { |
| 215 | if (!target.empty()) { |
| 216 | result = std::move(target); |
| 217 | } |
| 218 | } else if (status.GetPOSIX() == EINVAL |
| 219 | #ifdef _WIN32 |
| 220 | || status.GetWindows() == ERROR_NOT_A_REPARSE_POINT |
| 221 | #endif |
| 222 | ) { |
| 223 | // The path was not a symlink. |
| 224 | status = cmsys::Status::Success(); |
| 225 | } |
| 226 | return result; |
| 227 | } |
| 228 | |
| 229 | Control ImplBase::ResolveSymlink(Root root, std::string::size_type slash, |
| 230 | std::string::size_type next_slash, |
no test coverage detected