Skip to content

Commit d8e8908

Browse files
committed
[IO-553] Add
org.apache.commons.io.FilenameUtils.WINDOWS_ILLEGAL_FILE_NAME_CHARS.
1 parent fdcc71d commit d8e8908

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ The <action> type attribute can be add,update,fix,remove.
4747
<body>
4848
<!-- The release date is the date RC is cut -->
4949
<release version="2.7" date="tba" description="tba">
50+
<action issue="IO-553" dev="ggregory" type="update">
51+
Add org.apache.commons.io.FilenameUtils.WINDOWS_ILLEGAL_FILE_NAME_CHARS.
52+
</action>
5053
</release>
5154

5255
<release version="2.6" date="2017-10-15" description="Java 7 required, Java 9 supported.">

src/main/java/org/apache/commons/io/FilenameUtils.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,38 @@ public class FilenameUtils {
100100
*/
101101
private static final char UNIX_SEPARATOR = '/';
102102

103+
/**
104+
* The characters that are illegal in Windows file names.
105+
*
106+
* <ul>
107+
* <li>< (less than</li>
108+
* <li>> (greater than</li>
109+
* <li>: (colon</li>
110+
* <li>" (double quote</li>
111+
* <li>/ (forward slash</li>
112+
* <li>\ (backslash</li>
113+
* <li>| (vertical bar or pipe</li>
114+
* <li>? (question mark</li>
115+
* <li>* (asterisk</li>
116+
* <li>ASCII NUL (0)</li>
117+
* <li>Integer characters 1 through 31</li>
118+
* </ul>
119+
*
120+
* @since 2.7
121+
* @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx">Naming Files,
122+
* Paths, and Namespaces</a>
123+
*/
124+
public static final char[] WINDOWS_ILLEGAL_FILE_NAME_CHARS = {
125+
// @formatter:off
126+
// ASCII NULL
127+
0,
128+
// 1-31 may be allowed in file streams
129+
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,
130+
29, 30, 31,
131+
'<', '>', ':', '"', '/', '\\', '|', '?', '*'
132+
// @formatter:on
133+
};
134+
103135
/**
104136
* The Windows separator character.
105137
*/

0 commit comments

Comments
 (0)