| 471 | std::vector<std::string> key_parts; |
| 472 | |
| 473 | static Result<S3Path> FromString(const std::string& s) { |
| 474 | if (internal::IsLikelyUri(s)) { |
| 475 | return Status::Invalid( |
| 476 | "Expected an S3 object path of the form 'bucket/key...', got a URI: '", s, "'"); |
| 477 | } |
| 478 | const auto src = internal::RemoveTrailingSlash(s); |
| 479 | auto first_sep = src.find_first_of(kSep); |
| 480 | if (first_sep == 0) { |
| 481 | return Status::Invalid("Path cannot start with a separator ('", s, "')"); |
| 482 | } |
| 483 | if (first_sep == std::string::npos) { |
| 484 | return S3Path{std::string(src), std::string(src), "", {}}; |
| 485 | } |
| 486 | S3Path path; |
| 487 | path.full_path = std::string(src); |
| 488 | path.bucket = std::string(src.substr(0, first_sep)); |
| 489 | path.key = std::string(src.substr(first_sep + 1)); |
| 490 | path.key_parts = internal::SplitAbstractPath(path.key); |
| 491 | RETURN_NOT_OK(Validate(path)); |
| 492 | return path; |
| 493 | } |
| 494 | |
| 495 | static Status Validate(const S3Path& path) { |
| 496 | auto st = internal::ValidateAbstractPath(path.full_path); |
nothing calls this directly
no test coverage detected