Filename chars cause opening failed: EINVAL (Invalid argument)
android
Solution
Please refer to this page, you will find the full list.
http://en.wikipedia.org/wiki/Comparison_of_file_systems
Although that your sdcard might be internal and mount as FUSE, it might be still FAT32 filesystem. The valid characters for FAT32 are (according to the page):
Any byte except for values 0-31, 127 (DEL) and: `" * / : < > ? \ | + , . ; = []` (lowcase `a-z` are stored as `A-Z`). With VFAT LFN any Unicode except `NUL`
Problem
I'd like to create a file with the filename in the following format: `DAY-MONTH-YEAR--HOUR:MINUTE` but when I use `--` or/and `:` I'm getting `open failed: EINVAL` exception. I was trying to escape these chars but without joy. Is there any list of the forbidden filename chars? ``` String time = String.valueOf(c.get(Calendar.DAY_OF_MONTH)) + "-" + String.valueOf(c.get(Calendar.MONTH) + 1) + "-" + String.valueOf(c.get(Calendar.YEAR)) + "--" + String.valueOf(c.get(Calendar.HOUR)) + "\\:" + String.valueOf(c.get(Calendar.MINUTE)); bufOutstream = new BufferedOutputStream(new FileOutputStream(new File(env.getExternalStorageDirectory()+"/myapp/"+time+"."+fExtension))); ``` logcat: ``` 12-01 10:34:01.181 25839-26542/com.example.app W/System.err﹕ Caught IOException: /storage/sdcard0/myapp/1-12-2013--10\:34.aac: open failed: EINVAL (Invalid argument) ```