All file operations in IO and NIO area are working fine and well tested if the input is a real file. But if the input is a device, some operation may work incorrectly. The logic on how to handling devices, especially on Windows platforms, need to be revisited.
Here are some examples for the reserved names on windows.
File f = new File("nul");
f.getCanonicalPath(); // This is fixed in jdk-4858457
f.getAbsolutePath();
f.toPath().toAbsolutePath();
f.toPath().toRealPath();
In addition, when opening a file, if the file is a device, the operation flags shall be set correctly. For example, OPEN_EXISTING flag is usually used in such situation.
Here are some examples for the reserved names on windows.
File f = new File("nul");
f.getCanonicalPath(); // This is fixed in jdk-4858457
f.getAbsolutePath();
f.toPath().toAbsolutePath();
f.toPath().toRealPath();
In addition, when opening a file, if the file is a device, the operation flags shall be set correctly. For example, OPEN_EXISTING flag is usually used in such situation.
- relates to
-
JDK-6262148 FileOutputStream.open() on a windows device throws FileNotFoundException (win)
- Open
-
JDK-6176051 File.isFile() should return "false" for "con" on windows platform
- Closed
-
JDK-4858457 File.getCanonicalPath() throws IOException when invoked with "nul" (win)
- Closed
-
JDK-8003887 File.getCanonicalFile() does not resolve symlinks on MS Windows
- Resolved