When iterating over files I must check whether or not the file is available offline if the drive is a virtual drive
, for example.
When working with GDrive's "stream files" feature, files in the finder are either considered to be "available offline" or "online only". The very same feature exists for other cloud storage provider such as OneDrive, nextcloud, and dropbox. For my application, checking the state before accessing the file is super important to not trigger an unintentional download of the files through the virtual drive driver.
On windows, things are simple by checking the FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS
and FILE_ATTRIBUTE_RECALL_ON_OPEN
file attributes.
On Mac, I fail to find an equivalent but for iCloud. I am checking all kinds of attributes through the NSFileManager attributesOfItemAtPath
dictionary as well as the NSURL resourceValues
On OneDrive, it seems to do the trick to simply check if NSURLFileAllocatedSizeKey
is zero. GDrive however, seems to cache the data at some place and always reports NSURLFileAllocatedSizeKey
to be zero, even though the file is made available offline.
Clearly, there must be a tag / flag / attribute to query from the file system, right?