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

Method GetFileInfo

cpp/src/arrow/filesystem/gcsfs.cc:342–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340 const GcsOptions& options() const { return options_; }
341
342 Result<FileInfo> GetFileInfo(const GcsPath& path) {
343 if (path.object.empty()) {
344 auto meta = client_.GetBucketMetadata(path.bucket);
345 return GetFileInfoBucket(path, std::move(meta).status());
346 }
347 auto meta = client_.GetObjectMetadata(path.bucket, path.object);
348 Result<FileInfo> info = GetFileInfoObject(path, meta);
349 if (!info.ok() || info->type() != FileType::NotFound) {
350 return info;
351 }
352 // Not found case. It could be this was written to GCS with a different
353 // "Directory" convention, so if there is at least one object that
354 // matches the prefix we assume it is a directory.
355 std::string canonical = internal::EnsureTrailingSlash(path.object);
356 auto list_result = client_.ListObjects(path.bucket, gcs::Prefix(canonical));
357
358 for (auto&& object_metadata : list_result) {
359 if (!object_metadata) {
360 continue;
361 }
362 // If there is at least one valid result, it indicates this is a
363 // directory (at least one object exists that starts with "path/")
364 return FileInfo(path.full_path, FileType::Directory);
365 }
366 // Return the original not-found info if there was no valid result.
367 return info;
368 }
369
370 Result<FileInfoVector> GetFileInfo(const FileSelector& select) {
371 ARROW_ASSIGN_OR_RAISE(auto p, GcsPath::FromString(select.base_dir));

Callers

nothing calls this directly

Calls 15

EnsureTrailingSlashFunction · 0.85
DepthFunction · 0.85
ConcatAbstractPathFunction · 0.85
IOErrorFunction · 0.85
GetObjectMetadataMethod · 0.80
push_backMethod · 0.80
IsFileMethod · 0.80
FileInfoClass · 0.70
ToArrowStatusFunction · 0.70
emptyMethod · 0.45
statusMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected