MCPcopy Create free account
hub / github.com/apache/arrow / IsNonEmptyDirectory

Method IsNonEmptyDirectory

cpp/src/arrow/filesystem/s3fs.cc:2473–2494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2471 }
2472
2473 Result<bool> IsNonEmptyDirectory(const S3Path& path) {
2474 ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock());
2475
2476 S3Model::ListObjectsV2Request req;
2477 req.SetBucket(ToAwsString(path.bucket));
2478 req.SetPrefix(ToAwsString(path.key) + kSep);
2479 req.SetDelimiter(Aws::String() + kSep);
2480 req.SetMaxKeys(1);
2481 auto outcome = client_lock.Move()->ListObjectsV2(req);
2482 if (outcome.IsSuccess()) {
2483 const S3Model::ListObjectsV2Result& r = outcome.GetResult();
2484 // In some cases, there may be 0 keys but some prefixes
2485 return r.GetKeyCount() > 0 || !r.GetCommonPrefixes().empty();
2486 }
2487 if (IsNotFound(outcome.GetError())) {
2488 return false;
2489 }
2490 return ErrorToStatus(
2491 std::forward_as_tuple("When listing objects under key '", path.key,
2492 "' in bucket '", path.bucket, "': "),
2493 "ListObjectsV2", outcome.GetError());
2494 }
2495
2496 static FileInfo MakeDirectoryInfo(std::string dirname) {
2497 FileInfo dir;

Callers 1

GetFileInfoMethod · 0.80

Calls 7

ToAwsStringFunction · 0.85
StringClass · 0.85
IsNotFoundFunction · 0.85
ErrorToStatusFunction · 0.85
MoveMethod · 0.45
GetResultMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected