| 1602 | } |
| 1603 | |
| 1604 | Status GcsFileSystem::RenameFile(const string& src, const string& target) { |
| 1605 | if (!IsDirectory(src).ok()) { |
| 1606 | return RenameObject(src, target); |
| 1607 | } |
| 1608 | // Rename all individual objects in the directory one by one. |
| 1609 | std::vector<string> children; |
| 1610 | TF_RETURN_IF_ERROR( |
| 1611 | GetChildrenBounded(src, UINT64_MAX, &children, true /* recursively */, |
| 1612 | true /* include_self_directory_marker */)); |
| 1613 | for (const string& subpath : children) { |
| 1614 | TF_RETURN_IF_ERROR( |
| 1615 | RenameObject(JoinGcsPath(src, subpath), JoinGcsPath(target, subpath))); |
| 1616 | } |
| 1617 | return Status::OK(); |
| 1618 | } |
| 1619 | |
| 1620 | // Uses a GCS API command to copy the object and then deletes the old one. |
| 1621 | Status GcsFileSystem::RenameObject(const string& src, const string& target) { |