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

Method GetFileInfo

cpp/src/arrow/filesystem/azurefs.cc:1823–1856  ·  view source on GitHub ↗

\pre location.path is not empty.

Source from the content-addressed store, hash-verified

1821
1822 /// \pre location.path is not empty.
1823 Result<FileInfo> GetFileInfo(const DataLake::DataLakeFileSystemClient& adlfs_client,
1824 const AzureLocation& location,
1825 Azure::Nullable<std::string> lease_id = {}) {
1826 auto file_client = adlfs_client.GetFileClient(location.path);
1827 DataLake::GetPathPropertiesOptions options;
1828 options.AccessConditions.LeaseId = std::move(lease_id);
1829 try {
1830 FileInfo info{location.all};
1831 auto properties = file_client.GetProperties(options);
1832 if (properties.Value.IsDirectory) {
1833 info.set_type(FileType::Directory);
1834 } else if (internal::HasTrailingSlash(location.path)) {
1835 // For a path with a trailing slash, a Hierarchical Namespace storage account
1836 // may recognize a file (path with trailing slash removed). For consistency
1837 // with other arrow::FileSystem implementations we chose to return NotFound
1838 // because the trailing slash means the user was looking for a directory.
1839 info.set_type(FileType::NotFound);
1840 return info;
1841 } else {
1842 info.set_type(FileType::File);
1843 info.set_size(properties.Value.FileSize);
1844 }
1845 info.set_mtime(
1846 std::chrono::system_clock::time_point{properties.Value.LastModified});
1847 return info;
1848 } catch (const Core::RequestFailedException& exception) {
1849 if (exception.StatusCode == Http::HttpStatusCode::NotFound) {
1850 return FileInfo{location.all, FileType::NotFound};
1851 }
1852 return ExceptionToStatus(
1853 exception, "GetProperties for '", file_client.GetUrl(),
1854 "' failed. GetFileInfo is unable to determine whether the path exists.");
1855 }
1856 }
1857
1858 /// On flat namespace accounts there are no real directories. Directories are
1859 /// implied by empty directory marker blobs with names ending in "/" or there

Callers

nothing calls this directly

Calls 10

HasTrailingSlashFunction · 0.85
ExceptionToStatusFunction · 0.85
SkipStartingEmptyPagesFunction · 0.85
EnsureTrailingSlashFunction · 0.85
IsContainerNotFoundFunction · 0.85
RemoveTrailingSlashFunction · 0.70
GetPropertiesMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected