MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CreateDir

Method CreateDir

tensorflow/core/platform/cloud/gcs_file_system.cc:1543–1565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1541}
1542
1543Status GcsFileSystem::CreateDir(const string& dirname) {
1544 string bucket, object;
1545 TF_RETURN_IF_ERROR(ParseGcsPath(dirname, true, &bucket, &object));
1546 if (object.empty()) {
1547 bool is_bucket;
1548 TF_RETURN_IF_ERROR(BucketExists(bucket, &is_bucket));
1549 return is_bucket ? Status::OK()
1550 : errors::NotFound("The specified bucket ", dirname,
1551 " was not found.");
1552 }
1553
1554 const string dirname_with_slash = MaybeAppendSlash(dirname);
1555
1556 if (FileExists(dirname_with_slash).ok()) {
1557 return errors::AlreadyExists(dirname);
1558 }
1559
1560 // Create a zero-length directory marker object.
1561 std::unique_ptr<WritableFile> file;
1562 TF_RETURN_IF_ERROR(NewWritableFile(dirname_with_slash, &file));
1563 TF_RETURN_IF_ERROR(file->Close());
1564 return Status::OK();
1565}
1566
1567// Checks that the directory is empty (i.e no objects with this prefix exist).
1568// Deletes the GCS directory marker if it exists.

Callers 1

TESTFunction · 0.45

Calls 7

ParseGcsPathFunction · 0.85
NotFoundFunction · 0.85
MaybeAppendSlashFunction · 0.85
FileExistsFunction · 0.50
emptyMethod · 0.45
okMethod · 0.45
CloseMethod · 0.45

Tested by 1

TESTFunction · 0.36