ColdGrub1384 / LibTerm

iOS sandboxed terminal with Python, Lua and Clang
https://libterm.app
MIT License
639 stars 115 forks source link

Is it possible to change current working directory to iCloud Drive root? #5

Closed kevin-he-01 closed 5 years ago

kevin-he-01 commented 5 years ago

Description

Currently, it is not possible to access any files that is not stored in any sub-folder of iCloud Drive (that is, stored directly under the root of iCloud Drive or any other storage providers such as Dropbox or Google Drive)

Notes

I know that LibTerm can change working directory to folders created under the iCloud Drive by the little folder icon on the top-right corner, but that only allows viewing files created under a directory, not in the root of the storage location

Furthermore, it might not be possible due to iOS's restrictions on what directories an app can browse, but I wondered why Apple allow apps to read and even modify the contents under any sub-folders of a storage location, (iCloud Drive, Google Drive, etc.) but not directly under the drive root. (except for the native Files app, of course)

ColdGrub1384 commented 5 years ago

I think that's not possible because on iOS and macOS, iCloud Drive isn't simply a directory, it's a file provider. So, imagine we have this on our iCloud Drive root:

On Mac, (and in iOS it's like the same thing, but with different path) Pages, Keynote and Number folders are stored inside "~/Library/Mobile Documents" because they are part of apps.

~/Library/Mobile Documents contents:

"A folder" and "A file" are stored inside "~/Library/Mobile Documents/com\~apple\~CloudDocs"

com\~apple\~CloudDocs contents:

Files in iCloud Drive are separated between apps containers and user files, so the Files app don't give us access to iCloud Drive root. And if we would have access, for example, the "Pages" folder would be called "com\~apple\~Pages".

I used Mac as example because it's easier, but I know that on iOS it's the same thing but "~/Library/Mobile Documents" is on a different path.

kevin-he-01 commented 5 years ago

@ColdGrub1384 I understand that files that resides in iCloud Drive root is spread out in multiple locations, but I wondered if I can get access to specifically the location for all non-App folders: com~apple~CloudDocs/. I'm not an iOS app developer so I don't know if it is possible to let the app request access/permission to /private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/ — which contains only user files and folder and not App folders — at all. I'm not asking to access a folder with both regular files, folders along with App Folders.

If that is possible under the limitation/sandboxing of iOS, then it would be a feature request, if not, you can close this issue. I created this issue for the reason described below:

Intention of Creating this issue

In macOS, you can append a folder (or file) with a .nosync suffix so it will not sync with iCloud Drive even though it resides in the iCloud Drive file provider ~/Library/Mobile Documents/. I tried that in iOS using LibTerm, and it actually works. It disappeared in the Files app but is still visible in LibTerm: I can see it using ls command and I can cd into it: it is completely accessible. However, the next time I tried renaming a folder in the iCloud Drive root using the native Files app introduced in iOS 11, since storage provider root is not navigable using LibTerm, and adding the .nosync suffix. Then suddenly, the app warns, "Operation Failed, ..." . I forget that Files app cannot see such file and it is gone😲. It is suffixed with .nosync so it is not synced to any other device (like a Mac or PC) that has no restriction like iOS. Furthermore, the iCloud Drive root is the only place where LibTerm cannot reach.

If those data are not backed up before head, then the only way to recover that folder is to jailbreak the iPhone, or possibly use Elcomsoft Phone Breaker to break into an iTunes backup and navigate the filesystem under /private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/ since that folder cannot be seen in the Files App unlike any other folder but still exists on the iPhone and can even take storage space.

Luckily I have Time Machine backup on my Mac to be able to recover them, of course😀. But that "deleted" folder still occupies my iPhone's storage space.😢

ColdGrub1384 commented 5 years ago

Ok, I see. So, you have a folder inside the iCloud Drive root with the .nosync suffix so you can't view it inside the Files app and it's not synced with iCloud Drive, and you can't delete it? You could try to sign out from your iCloud account and sign in again. But, I'm not sure if the folder will be deleted because it's not synced.