Hi, so as I understand it is not possible to know what all possible sources of files are available on iOS using some api call (by sources I mean smb shares connected, iCloud, gdrive, etc), the only paths I can get are the app sandbox, app group container and the same on iCloud. I can get the list of mount points in macOS using getmntinfo(), app/group sandbox and apart from these whatever standard locations I have given access to to my sandboxed app. Are there other paths that I can get?
I want to know how I can determine the volume given a user picks a file using a file picker. Say, they picked 10 files from gdrive and another 5 from local storage. If I encounter some errors on the files from gdrive I want to stop working on all 10 of them but to do that I need to be able to determine that that are on this particular volume. Is there a way to do this programmatically?
Ex: gdrive on iOS : "/private/var/mobile/Containers/Shared/AppGroup/6208BBEE-24BF-4CC9-A9ED-846F987C0442/File Provider Storage/39822865/1P8WD1tWEaq81ZB_DodTTZhXm0p00QaF7/test.txt" on MacOS: "/Users/username/Library/CloudStorage/GoogleDrive-useremailid/My Drive"
Are there other paths that I can get?
The exact extent of the static sandbox is not documented as API. I talk about this in On File System Permissions.
Oh, and while getmntinfo
works, the mountedVolumeURLs(includingResourceValuesForKeys:options:)
method is probably a better choice.
I need to be able to determine that that are on this particular volume. Is there a way to do this programmatically?
Sure. You can do this at a variety of different layers. My general advice is that you do file system stuff using FileManager
and URL
. In this case, the volumeIdentifierKey
resource key is the droid you’re looking for. However, I recommend that you survey the list of these keys but there’s a lot of really useful info in there. For example, volumeURLKey
returns the URL of the volume on which a file system object resides.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"