| 1119 | } |
| 1120 | |
| 1121 | Status GcsFileSystem::FileExists(const string& fname) { |
| 1122 | string bucket, object; |
| 1123 | TF_RETURN_IF_ERROR(ParseGcsPath(fname, true, &bucket, &object)); |
| 1124 | if (object.empty()) { |
| 1125 | bool result; |
| 1126 | TF_RETURN_IF_ERROR(BucketExists(bucket, &result)); |
| 1127 | if (result) { |
| 1128 | return Status::OK(); |
| 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | // Check if the object exists. |
| 1133 | GcsFileStat stat; |
| 1134 | const Status status = StatForObject(fname, bucket, object, &stat); |
| 1135 | if (status.code() != errors::Code::NOT_FOUND) { |
| 1136 | return status; |
| 1137 | } |
| 1138 | |
| 1139 | // Check if the folder exists. |
| 1140 | bool result; |
| 1141 | TF_RETURN_IF_ERROR(FolderExists(fname, &result)); |
| 1142 | if (result) { |
| 1143 | return Status::OK(); |
| 1144 | } |
| 1145 | return errors::NotFound("The specified path ", fname, " was not found."); |
| 1146 | } |
| 1147 | |
| 1148 | Status GcsFileSystem::ObjectExists(const string& fname, const string& bucket, |
| 1149 | const string& object, bool* result) { |