Skip to content

Commit e26b036

Browse files
committed
[FS] Treat ERROR_PATH_NOT_FOUND in Win32Handler as file does not exist
If it is attempted to fetch the file-info of a file, whose parent directory does not exist the error code is ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND. The latter is only returned if a file does not exist in an existing parent directory. Therefore in case of ERROR_FILE_NOT_FOUND the file should just be treated as not existing without setting an IO_ERROR. The JDK's java.nio file-system implementation for Windows also considers a file as absent (i.e. throws a NoSuchFileException) for both error codes ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND.
1 parent cbfee18 commit e26b036

File tree

1 file changed

+2
-1
lines changed
  • resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local

1 file changed

+2
-1
lines changed

resources/bundles/org.eclipse.core.filesystem/src/org/eclipse/core/internal/filesystem/local/Win32Handler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public FileInfo fetchFileInfo(String fileName) {
6868
long handle = FileAPIh.FindFirstFileW(new WString(target), mem);
6969
if (handle == FileAPIh.INVALID_HANDLE_VALUE) {
7070
int error = Native.getLastError();
71-
if (error != WinError.ERROR_FILE_NOT_FOUND) {
71+
if (!(error == WinError.ERROR_FILE_NOT_FOUND // file not found in existing parent directory
72+
|| error == WinError.ERROR_PATH_NOT_FOUND)) { // Not even the parent directory exists
7273
fileInfo.setError(IFileInfo.IO_ERROR);
7374
}
7475
return fileInfo;

0 commit comments

Comments
 (0)