https://issues.apache.org/bugzilla/show_bug.cgi?id=42141

--- Comment #11 from Michel Nolard <michel.nol...@gmail.com> 2011-09-19 
08:49:11 UTC ---

[Warning: long comment]

Great ! I am quite happy to see things are moving on this point.

First, this is a usability _bug_ and not _enhancement_ (although one may say
that a fix for a bug enhances the experience...), as the visual feedback shown
to the user works against what is actually done. Correct feedback is not a
feature to be eventually added, but it is part of the application's good
behaviour.

Second, I agree that restricting the set of allowed characters arbitrarily and
in a platform independent way is not wise and would be a source of many more
complaints. We know that some file systems accepts only 8.3 file names while
others allow nearly the full UTF-8 range of values. This makes a point to an
OS-specific adaptation solution.

Third, here are two links for those who want to know that, finally, there is no
good way to check a filename conformance to the OS rules in Java 6 although
there is one in Java 7 :
http://stackoverflow.com/questions/893977/java-how-to-find-out-whether-a-file-name-is-valid
http://stackoverflow.com/questions/122400/what-are-reserved-filenames-for-various-platforms

Fourth, under Linux/Unix, only the slash ('/') is forbidden as a pure file name
character, while it is not when part of its path. The same limitation stands
under Windows with the backslash ('\') but there are some others more too.

Finally, my proposal, hoping this makes everyone happy :
 * The problem is on the feedback, so there is not a real need to jump onto the
technical limitation of the filename by enforcing it too early.
 * As the OS does already well that job as it knows itself quite well, why
don't we rely on it simply ?
 * In the following snippet, when using an illegal filename instead of the
'xxx', an exception is thrown (error message under Windows is shown just under
the java sample) :
-----8<---------8<----
    /* 1 */    File foobar = new File( "xxx" );
    /* 2 */    foobar.getParentFile().mkdirs();
    /* 3 */    foobar.createNewFile();
-----8<---------8<----

-----8<---------8<----
    java.io.FileNotFoundException: 'xxx' (The filename, directory name, or
volume label syntax is incorrect)
-----8<---------8<----

 * Please, note that the second line which allows the user to insert the
directory separator safely.
 * Please, notice that createNewFile() returns a boolean _and_ may throw at the
same time.

So the actual solution I propose for all platforms :
 - allow anything to be typed in by the user as a filename,
 - use the "second line trick" (getParentFile().mkdirs()) to avoid directory
separator problems,
 - try to create the file using createNewFile() and redisplay the file save
dialog whenever an exception is thrown, while showing the error message to the
user so that she can correct the filename accordingly,
 - _never ever_ change the user's input without at least telling her.

Hoping this will help a bit,

Thanks for your attention.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@jakarta.apache.org
For additional commands, e-mail: notifications-h...@jakarta.apache.org

Reply via email to