diff --git a/src/main/java/com/helger/jcodemodel/util/JCFilenameHelper.java b/src/main/java/com/helger/jcodemodel/util/JCFilenameHelper.java index e8f514ed..8778c1a4 100644 --- a/src/main/java/com/helger/jcodemodel/util/JCFilenameHelper.java +++ b/src/main/java/com/helger/jcodemodel/util/JCFilenameHelper.java @@ -65,10 +65,10 @@ public final class JCFilenameHelper public static final char ILLEGAL_FILENAME_CHAR_REPLACEMENT = '_'; /** Special name of the current path */ - public static final String PATH_CURRENT = "."; + public static final String UNIX_PATH_CURRENT = "."; /** Special name of the parent path */ - public static final String PATH_PARENT = ".."; + public static final String UNIX_PATH_PARENT = ".."; /** The Unix path separator character. */ public static final char UNIX_SEPARATOR = '/'; @@ -102,15 +102,14 @@ public final class JCFilenameHelper * Illegal characters in Windows file names.
* see http://en.wikipedia.org/wiki/Filename */ - private static final char [] ILLEGAL_CHARACTERS_WINDOWS = { 0, '<', '>', '?', '*', ':', '|', '"' }; - private static final char [] ILLEGAL_CHARACTERS_OTHERS = { 0, '<', '>', '?', '*', '|', '"' }; + private static final char [] WINDOWS_ILLEGAL_CHARACTERS = { 0, '<', '>', '?', '*', ':', '|', '"' }; /** * see http://www.w3.org/TR/widgets/#zip-relative
* see http://forum.java.sun.com/thread.jspa?threadID=544334&tstart=165
* see http://en.wikipedia.org/wiki/Filename */ - private static final String [] ILLEGAL_PREFIXES = { "CLOCK$", + private static final String [] WINDOWS_ILLEGAL_PREFIXES = { "CLOCK$", "CON", "PRN", "AUX", @@ -133,7 +132,7 @@ public final class JCFilenameHelper "LPT8", "LPT9" }; - private static final char [] ILLEGAL_SUFFIXES = new char [] { '.', ' ', '\t' }; + private static final char [] WINDOWS_ILLEGAL_SUFFIXES = new char [] { '.', ' ', '\t' }; static { @@ -226,14 +225,9 @@ public static boolean isValidLinuxFilename (@Nullable final String sFilename) return false; // Check for reserved directories - if (PATH_CURRENT.equals (sFilename) || PATH_PARENT.equals (sFilename)) + if (UNIX_PATH_CURRENT.equals (sFilename) || UNIX_PATH_PARENT.equals (sFilename)) return false; - // Check if file name contains any of the illegal characters - for (final char cIllegal : ILLEGAL_CHARACTERS_OTHERS) - if (sFilename.indexOf (cIllegal) != -1) - return false; - return true; } @@ -259,20 +253,20 @@ public static boolean isValidWindowsFilename (@Nullable final String sFilename) return false; // Check for reserved directories - if (PATH_CURRENT.equals (sFilename) || PATH_PARENT.equals (sFilename)) + if (UNIX_PATH_CURRENT.equals (sFilename) || UNIX_PATH_PARENT.equals (sFilename)) return false; // check for illegal last characters - if (JCStringHelper.endsWithAny (sFilename, ILLEGAL_SUFFIXES)) + if (JCStringHelper.endsWithAny (sFilename, WINDOWS_ILLEGAL_SUFFIXES)) return false; // Check if file name contains any of the illegal characters - for (final char cIllegal : ILLEGAL_CHARACTERS_WINDOWS) + for (final char cIllegal : WINDOWS_ILLEGAL_CHARACTERS) if (sFilename.indexOf (cIllegal) != -1) return false; // check prefixes directly - for (final String sIllegalPrefix : ILLEGAL_PREFIXES) + for (final String sIllegalPrefix : WINDOWS_ILLEGAL_PREFIXES) if (sFilename.equalsIgnoreCase (sIllegalPrefix)) return false; @@ -280,7 +274,7 @@ public static boolean isValidWindowsFilename (@Nullable final String sFilename) // Note: we can use the default locale, since all fixed names are pure ANSI // names final String sUCFilename = sFilename.toUpperCase (Locale.ROOT); - for (final String sIllegalPrefix : ILLEGAL_PREFIXES) + for (final String sIllegalPrefix : WINDOWS_ILLEGAL_PREFIXES) if (sUCFilename.startsWith (sIllegalPrefix + ".")) return false;