Reputation: 11
I have an app that has to create files and directories on the removable sdcard. I use the DocumentFile API. In most of cases, it works, but I have found one case which doesn't work (at least on a Samsung GS7):
I cannot create a directory named "R.E.M." (without quotes).
Test case: I'm working in directory "/storage/9C33-6BBD/Xxxx", I want to create directory "R.E.M."
DocumentFile parentDf;
// init of parentDf to point to /storage/9C33-6BBD/Xxxx
DocumentFile remDf = df.createDirectory("R.E.M.");
if(remDf == null)
displayMessage("failure");
else
displayMessage("success");
This will display "success", so I'm Happy. Latter I want to create a file in this directory: "R.E.M./myfile".
DocumentFile parentDf;
// init of parentDf to point to /storage/9C33-6BBD/Xxxx
DocumentFile remDf = parentDf.findFile("R.E.M.");
if(remDf == null) {
displayMessage("failure : R.E.M. doesn't exists");
return false;
}
DocumentFile myfileDf = remDf.createFile("text/plain","myfile");
if(remDf == null)
displayMessage("failure");
else
displayMessage("success");
This will display "failure: R.E.M. doesn't exists"
so I list files with DocumentFile.listFiles and see: "R.E.M" (the last DOT has gone away !)
if I do (new File("/storage/9C33-6BBD/Xxxx/R.E.M.")).exists()
it returns true!
If I take a look with "adb shell"
hero2lte:/storage/9C33-6BBD/Xxxx $ ls -la
total 768
drwxrwx--x 3 root sdcard_rw 131072 2017-07-19 14:18 .
drwxrwx--x 17 root sdcard_rw 131072 2017-07-19 13:31 ..
drwxrwx--x 2 root sdcard_rw 131072 2017-07-19 13:46 R.E.M
hero2lte:/storage/9C33-6BBD/Xxxx $ ls -lad R.E.M.
drwxrwx--x 2 root sdcard_rw 131072 2017-07-19 13:46 R.E.M.
Does anyone know where I can find documentation about directories displayName limitations?
thanks
Upvotes: 0
Views: 381
Reputation: 11
Actually this is not a DocumentFile API limitation, but simply a filesystem limitation : Microsoft filesystems (at least VFAT and NTFS) doesn't support directories names ending with a DOT (.) .
Upvotes: 1