On 15 November 2017 at 13:34, Gary Gregory <garydgreg...@gmail.com> wrote:
> On Nov 15, 2017 03:44, "sebb" <seb...@gmail.com> wrote:
>
> On 15 November 2017 at 04:13,  <ggreg...@apache.org> wrote:
>> Repository: commons-io
>> Updated Branches:
>>   refs/heads/master fdcc71dcd -> d8e8908db
>>
>>
>> [IO-553] Add
>> org.apache.commons.io.FilenameUtils.WINDOWS_ILLEGAL_FILE_NAME_CHARS.
>>
>> Project: http://git-wip-us.apache.org/repos/asf/commons-io/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/commons-io/commit/d8e8908d
>> Tree: http://git-wip-us.apache.org/repos/asf/commons-io/tree/d8e8908d
>> Diff: http://git-wip-us.apache.org/repos/asf/commons-io/diff/d8e8908d
>>
>> Branch: refs/heads/master
>> Commit: d8e8908db227ec91608b386a65b5f8559d92d8c9
>> Parents: fdcc71d
>> Author: Gary Gregory <ggreg...@apache.org>
>> Authored: Tue Nov 14 21:13:46 2017 -0700
>> Committer: Gary Gregory <ggreg...@apache.org>
>> Committed: Tue Nov 14 21:13:46 2017 -0700
>>
>> ----------------------------------------------------------------------
>>  src/changes/changes.xml                         |  3 ++
>>  .../org/apache/commons/io/FilenameUtils.java    | 32 ++++++++++++++++++++
>>  2 files changed, 35 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-io/blob/
> d8e8908d/src/changes/changes.xml
>> ----------------------------------------------------------------------
>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>> index 4e74185..7ad3fcc 100644
>> --- a/src/changes/changes.xml
>> +++ b/src/changes/changes.xml
>> @@ -47,6 +47,9 @@ The <action> type attribute can be
> add,update,fix,remove.
>>    <body>
>>      <!-- The release date is the date RC is cut -->
>>      <release version="2.7" date="tba" description="tba">
>> +      <action issue="IO-553" dev="ggregory" type="update">
>> +        Add org.apache.commons.io.FilenameUtils.WINDOWS_ILLEGAL_
> FILE_NAME_CHARS.
>> +      </action>
>>      </release>
>>
>>      <release version="2.6" date="2017-10-15" description="Java 7
> required, Java 9 supported.">
>>
>> http://git-wip-us.apache.org/repos/asf/commons-io/blob/
> d8e8908d/src/main/java/org/apache/commons/io/FilenameUtils.java
>> ----------------------------------------------------------------------
>> diff --git a/src/main/java/org/apache/commons/io/FilenameUtils.java
> b/src/main/java/org/apache/commons/io/FilenameUtils.java
>> index 9cddebb..b08ab91 100644
>> --- a/src/main/java/org/apache/commons/io/FilenameUtils.java
>> +++ b/src/main/java/org/apache/commons/io/FilenameUtils.java
>> @@ -101,6 +101,38 @@ public class FilenameUtils {
>>      private static final char UNIX_SEPARATOR = '/';
>>
>>      /**
>> +     * The characters that are illegal in Windows file names.
>> +     *
>> +     * <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>
>> +     * </ul>
>> +     *
>> +     * @since 2.7
>> +     * @see <a href="https://msdn.microsoft.com/en-us/library/windows/
> desktop/aa365247(v=vs.85).aspx">Naming Files,
>> +     *      Paths, and Namespaces</a>
>> +     */
>> +    public static final char[] WINDOWS_ILLEGAL_FILE_NAME_CHARS = {
>
> -1
>
> array elements are mutable!!
>
> Any code can deliberately or accidentally change one or more entries.
>
> Only empty arrays are immutable.
>
>
> Ok, I can make it a String.

That would do, but it would be better to provide a method to check its
input against the list.
Otherwise people are going to have to do that themselves.

You can do both: expose the String and add a method which uses it.

> So you are saying that we should never provide
> char[] constants?

Amongst others.
String[] constants are also mutable.
As are int[], long[], etc[].

Only *empty* arrays are immutable; they don't have any entries.

Other arrays which are intended to be constant must either be cloned
for external classes or not be exposed.

> Gary
>
>
>> +            // @formatter:off
>> +            // ASCII NULL
>> +            0,
>> +            // 1-31 may be allowed in file streams
>> +            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
> 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
>> +            29, 30, 31,
>> +            '<', '>', ':', '"', '/', '\\', '|', '?', '*'
>> +            // @formatter:on
>> +    };
>> +
>> +    /**
>>       * The Windows separator character.
>>       */
>>      private static final char WINDOWS_SEPARATOR = '\\';
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org

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

Reply via email to