| 59 | std::string object; |
| 60 | |
| 61 | static Result<GcsPath> FromString(const std::string& s) { |
| 62 | if (internal::IsLikelyUri(s)) { |
| 63 | return Status::Invalid( |
| 64 | "Expected a GCS object path of the form 'bucket/key...', got a URI: '", s, "'"); |
| 65 | } |
| 66 | const auto first_sep = s.find_first_of(internal::kSep); |
| 67 | if (first_sep == 0) { |
| 68 | return Status::Invalid("Path cannot start with a separator ('", s, "')"); |
| 69 | } |
| 70 | if (first_sep == std::string::npos) { |
| 71 | return GcsPath{s, std::string(internal::RemoveTrailingSlash(s)), ""}; |
| 72 | } |
| 73 | GcsPath path; |
| 74 | path.full_path = s; |
| 75 | path.bucket = s.substr(0, first_sep); |
| 76 | path.object = s.substr(first_sep + 1); |
| 77 | RETURN_NOT_OK(Validate(path)); |
| 78 | return path; |
| 79 | } |
| 80 | |
| 81 | static Status Validate(const GcsPath& path) { |
| 82 | auto st = internal::ValidateAbstractPath(path.full_path); |
nothing calls this directly
no test coverage detected