Description
Per Microsoft documentation, the following filenames are also reserved filenames: LPT¹, LPT², LPT³, COM¹, COM² and COM³.
As far as I can tell, only the non-superscript filenames are marked as illegal in the FileSystem.WINDOWS enum. These six filenames should also be added as reserved filenames, as they can not be used for regular files. (e.g. trying to create a file called COM³ will fail).
Quote from the microsoft documentation:
Windows recognizes the 8-bit ISO/IEC 8859-1 superscript digits ¹, ², and ³ as digits and treats them as valid parts of COM# and LPT# device names, making them reserved in every directory.
Testing code to reproduce: (there should be no output)
import org.apache.commons.io.FileSystem; public class FilenameTest { public static void main(String[] args) { char[] digitsWithSuperScript = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '¹', '²', '³'}; for (String filenamesPrefix : new String[]{"LPT", "COM"}) { for (char digit : digitsWithSuperScript) { final String filename = filenamesPrefix + digit; checkFilename(filename, true); // Base filename should be reserved checkFilename(filename + ".tar.gz", true); // Extensions should be ignored checkFilename(filename + ".txt", true); // Non-extension suffixes are ok. checkFilename(filename + "additional_text", false); } } for (String reservedFileName : new String[]{"CON", "PRN", "AUX", "NUL", "CONIN$", "CONOUT$"}) { // Base filename should be reserved checkFilename(reservedFileName, true); // Extensions should be ignored checkFilename(reservedFileName + ".tar.gz", true); // Non-extension suffixes are ok. checkFilename(reservedFileName + "additional_text", false); } } static void checkFilename(String filename, boolean isReserved) { boolean isReservedAccordingToAPI = FileSystem.WINDOWS.isReservedFileName(filename); if (isReserved != isReservedAccordingToAPI) { if (isReserved) { System.out.printf("'%s' is reserved according to the spec but not according to FileSystem.isReservedFileName%n", filename); } else { System.out.printf("'%s' is not reserved according to the spec but is according to FileSystem.isReservedFileName%n", filename); } } else { // Spec and API match } } }
Link to relevant code: