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

Method ToFileInfo

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

The normalize_directories parameter is needed because how a directory is listed. If a specific path is asked for with a trailing slash it is expected to have a trailing slash [1] but for recursive listings it is expected that directories have their path normalized [2]. [1] https://github.com/apache/arrow/blob/3eaa7dd0e8b3dabc5438203331f05e3e6c011e37/python/pyarrow/tests/test_fs.py#L688 [2] https:

Source from the content-addressed store, hash-verified

679 // [2]
680 // https://github.com/apache/arrow/blob/3eaa7dd0e8b3dabc5438203331f05e3e6c011e37/cpp/src/arrow/filesystem/test_util.cc#L767
681 static FileInfo ToFileInfo(const std::string& full_path,
682 const gcs::ObjectMetadata& meta,
683 bool normalize_directories = false) {
684 if (IsDirectory(meta) || (!full_path.empty() && full_path.back() == '/')) {
685 if (normalize_directories) {
686 auto normalized = std::string(internal::RemoveTrailingSlash(full_path));
687 return FileInfo(std::move(normalized), FileType::Directory);
688 } else {
689 return FileInfo(full_path, FileType::Directory);
690 }
691 }
692 auto info = FileInfo(full_path, FileType::File);
693 info.set_size(static_cast<int64_t>(meta.size()));
694 // An object has multiple "time" attributes, including the time when its data was
695 // created, and the time when its metadata was last updated. We use the object
696 // creation time because the data for an object cannot be changed once created.
697 info.set_mtime(meta.time_created());
698 return info;
699 }
700
701 GcsOptions options_;
702 gcs::Client client_;

Callers

nothing calls this directly

Calls 6

backMethod · 0.80
IsDirectoryFunction · 0.70
RemoveTrailingSlashFunction · 0.70
FileInfoClass · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected