coryan commented on a change in pull request #11943:
URL: https://github.com/apache/arrow/pull/11943#discussion_r768767562
##########
File path: cpp/src/arrow/filesystem/gcsfs.cc
##########
@@ -285,6 +285,41 @@ class GcsFileSystem::Impl {
path.object.back() == '/' ? FileType::Directory : FileType::File);
}
+ Result<FileInfoVector> GetFileInfo(const FileSelector& select) {
+ ARROW_ASSIGN_OR_RAISE(auto p, GcsPath::FromString(select.base_dir));
+ auto prefix = p.object.empty() ? gcs::Prefix() : gcs::Prefix(p.object);
+ auto delimiter = select.recursive ? gcs::Delimiter() : gcs::Delimiter("/");
+ bool found_directory = false;
+ FileInfoVector result;
+ for (auto const& o : client_.ListObjects(p.bucket, prefix, delimiter)) {
+ if (!o.ok()) {
+ if (select.allow_not_found &&
+ o.status().code() == google::cloud::StatusCode::kNotFound) {
+ continue;
+ }
+ return internal::ToArrowStatus(o.status());
+ }
+ found_directory = true;
+ // Skip the directory itself from the results
+ if (o->name() == p.object) {
+ continue;
+ }
+ auto path = internal::ConcatAbstractPath(o->bucket(), o->name());
+ if (o->name().back() == '/') {
+ result.push_back(
+ FileInfo(internal::EnsureTrailingSlash(path),
FileType::Directory));
+ continue;
+ }
+ auto info = FileInfo(path, FileType::File);
+ info.set_size(static_cast<int64_t>(o->size()));
Review comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]