coryan commented on a change in pull request #11943:
URL: https://github.com/apache/arrow/pull/11943#discussion_r768709002
##########
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:
Object media (aka data, aka contents) are immutable once created, so the
mtime could be initialized from `o->time_created()`. Object metadata is not
immutable, and when changed it resets `o->updated()`. I am not sure which one
you wanted so I went with `o->updated()`, I can change it if you think
`o->time_created()` is a better choice.
--
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]