File: mergeall-products/unzipped/test/ziptools/docetc/illegal-filenames-demo-1.3/sh-android11-illegal-and-folders-bug.txt

Demo Android filename-character rules.

Android's filename rules vary per storage type and version: shared storage
(/sdcard) may impose the same filename-character rules as Windows, but 
app-specific storage (/sdcard/Android/data/app) does not.  This varies per
Android version, and perhaps vendor.  Two Android 11 devices tested disallow
illegals in shared storage, because it uses a FUSE driver; but an Android 10 
device does not, because its shared storage uses SDCardFS.  No tested device
disallows Windows illegals in app-specific or app-private storage, which use
Linux ext4.  Per Bash in Termux on Android 11:

$ cd /sdcard                                # shared storage
$ echo xxx > test\?.txt
bash: test?.txt: Operation not permitted
$ echo xxx > test\|.txt
bash: test|.txt: Operation not permitted

$ cd /sdcard/Android/data/com.termux        # app-specific storage
$ echo xxx > test\?.txt
$ echo xxx > test\|.txt
 
$ cd /data/data/com.termux                  # app-private storage
$ echo xxx > test\?.txt
$ echo xxx > test\|.txt

Convolutedly, this Android's shared storage disallows nonportables in 
files but not folders - though Windows disallows them in both:
 
$ cd /sdcard
$ mkdir test\?dir
$ mkdir test\|dir                           # but folder names differ
$ ls test*dir
'test?dir':
'test|dir':

Worse, Android does not allow any files to be created in such folders 
even if they are fully portable, even though subfolders pass:

$ echo xxx > test\|dir/testfile
bash: test|dir/testfile: Operation not permitted
$
$ mkdir test\|dir/sub
$
$ cd test\|dir
$ ls
sub
$ echo xxx > testfile
bash: testfile: Operation not permitted

This breaks extracts: no files can be stored in folders with nonportable
names, even if the files are portable.  Either mangling must be a known
requirement before saving anything, or files and folders must be mangled
ahead of time; see fix-nonportable-filenames.py for the latter.



[Home page] Books Code Blog Python Author Train Find ©M.Lutz