JFLib

plat/android_files.rs#

Source: lib/plat/android_files.rs

Android's files: the virtual names of the host adapter (/config, /data, /cache, /tmp,
/documents, /imports -- the same as in the browser, so the permissions and the vfs see one
layout) on real files of the app's internal storage, through Bionic.  They survive restarts.

  /cache/..  -> <cacheDir>/cache/..   (the system may clear it when storage runs low)
  /tmp/..    -> <cacheDir>/tmp/..     (emptied when the app starts)
  /system/.., /product/.., /proc/.. and the other folders of the system's own (SYSTEM): the
             real paths (fonts, certificates, /proc; read only for an app)
  /..        -> <filesDir>/fs/..      (config, data, documents, imports and anything else)
GalleryActivity passes filesDir / cacheDir before the start (jfgui_ANDROID_FILES,
jfgui_ANDROID_CACHE); without them every file call fails but those of the system's folders.
The app's storage has no real name here: /data is a virtual name (docs/ANDROID.md AN3).
plat::fs and plat::watch take the same names (os_z: the kernel's calls on the real path).

write_file and AtomicFile write a sibling "NAME.tmp-PID-SEQ-TIME", fsync it and rename it
over the target (readers see the old or the new file, also after a crash).  FileLock is
flock (across processes of the app).  open_temp unlinks its file at once.  Writing needs the
folder to exist (as on Linux; config:// etc. create theirs).  The documents of other apps
are content:// names (content.rs, android_host.rs), not paths.
  • fn cwd() -> String Current virtual directory; it is unrelated to the process's working directory.

  • fn config_dir() -> Option<String> The app's settings below internal storage.

  • fn data_dir() -> Option<String> The app's data below internal storage.

  • fn cache_dir() -> Option<String> The cache below the app's cache folder (the system may clear it).

  • fn temp_dir() -> Option<String> Temporary files (emptied when the app starts).

  • fn home() -> Option<String> The app's own documents (internal storage; the user's documents are content:// names).

  • fn drives() -> Vec<String> One virtual root.

  • fn dev_ino(_path: &str) -> Option<(u64, u64)> Device / inode identity is not exposed for the virtual names.

Source: docs/API.md in the JFLib repository.