commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-555) Add org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char)
Date Wed, 15 Nov 2017 18:49:00 GMT

    [ https://issues.apache.org/jira/browse/IO-555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16253942#comment-16253942
] 

Sebb commented on IO-555:
-------------------------

I meant that {{isIllegalFileNameChar(final char c)}} is not flexible from the point of view
of the caller.
I don't see much of a use case for checking individual chars for validity.
Whereas CharSequence (or String) could be quite useful.

The Javadoc does not mention that the input filename may be truncated.

There's no check to ensure the replacement character is valid.
It might be useful to allow illegal chars to be dropped.
In which case truncation should be done last.

Also, what units are the maximum name and path lengths measured in?
I would guess bytes, however the code assumes chars, which is not the same.

> Add org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char)
> ----------------------------------------------------------------------
>
>                 Key: IO-555
>                 URL: https://issues.apache.org/jira/browse/IO-555
>             Project: Commons IO
>          Issue Type: Improvement
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 2.7
>
>
> Add {{org.apache.commons.io.FilenameUtils.isIllegalWindowsFileName(char)}}.
> {code:java}
>     /**
>      * Checks whether the given character is illegal in a Windows file names.
>      * <p>
>      * The illegal character are:
>      * </p>
>      * <ul>
>      * <li>< (less than</li>
>      * <li>> (greater than</li>
>      * <li>: (colon</li>
>      * <li>" (double quote</li>
>      * <li>/ (forward slash</li>
>      * <li>\ (backslash</li>
>      * <li>| (vertical bar or pipe</li>
>      * <li>? (question mark</li>
>      * <li>* (asterisk</li>
>      * <li>ASCII NUL (0)</li>
>      * <li>Integer characters 1 through 31</li>
>      * <li>There may be other characters that the file name does not allow. Please
see
>      * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">Naming
Files, Paths,
>      * and Namespaces</a></li>
>      * </ul>
>      * 
>      * @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">Naming
Files,
>      *      Paths, and Namespaces</a>
>      * @param c
>      *            the character to check
>      * @return whether the give character is legal
>      * @since 2.7
>      */
> {code}
> I use this method as a building block to create file names based on Strings from other
sources.
> A further contribution could be: {{String toLegalWindowsFileName(String input, char replacementChar)}}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message