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

Method IsNonEmptyDirectory

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

Source from the content-addressed store, hash-verified

2410 }
2411
2412 Result<bool> IsNonEmptyDirectory(const S3Path& path) {
2413 ARROW_ASSIGN_OR_RAISE(auto client_lock, holder_->Lock());
2414
2415 S3Model::ListObjectsV2Request req;
2416 req.SetBucket(ToAwsString(path.bucket));
2417 req.SetPrefix(ToAwsString(path.key) + kSep);
2418 req.SetDelimiter(Aws::String() + kSep);
2419 req.SetMaxKeys(1);
2420 auto outcome = client_lock.Move()->ListObjectsV2(req);
2421 if (outcome.IsSuccess()) {
2422 const S3Model::ListObjectsV2Result& r = outcome.GetResult();
2423 // In some cases, there may be 0 keys but some prefixes
2424 return r.GetKeyCount() > 0 || !r.GetCommonPrefixes().empty();
2425 }
2426 if (IsNotFound(outcome.GetError())) {
2427 return false;
2428 }
2429 return ErrorToStatus(
2430 std::forward_as_tuple("When listing objects under key '", path.key,
2431 "' in bucket '", path.bucket, "': "),
2432 "ListObjectsV2", outcome.GetError());
2433 }
2434
2435 static FileInfo MakeDirectoryInfo(std::string dirname) {
2436 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