server: Don't always return STATUS_OBJECT_NAME_INVALID on ENOTDIR.

Only return STATUS_OBJECT_NAME_INVALID if we're not looking for a
FILE_DIRECTORY_FILE.
This commit is contained in:
Brendan McGrath 2024-05-29 11:52:18 +10:00 committed by Alexandre Julliard
parent a0c2f40b4e
commit d88863805d
3 changed files with 1 additions and 3 deletions

View file

@ -2769,7 +2769,6 @@ static void test_FindFirstFileA(void)
handle = FindFirstFileA(buffer2, &data);
err = GetLastError();
ok ( handle == INVALID_HANDLE_VALUE, "FindFirstFile on %s should fail\n", buffer2 );
todo_wine
ok ( err == ERROR_DIRECTORY, "Bad Error number %x\n", err );
}

View file

@ -419,7 +419,6 @@ static void open_file_test(void)
status = NtOpenFile( &handle, FILE_LIST_DIRECTORY | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT | FILE_OPEN_FOR_BACKUP_INTENT );
todo_wine
ok( status == STATUS_NOT_A_DIRECTORY, "open %s failed %lx\n", wine_dbgstr_w(nameW.Buffer), status );
CloseHandle( handle );
pRtlFreeUnicodeString( &nameW );

View file

@ -1942,7 +1942,7 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
if (fd->unix_fd == -1)
{
/* check for trailing slash on file path */
if ((errno == ENOENT || errno == ENOTDIR) && name[strlen(name) - 1] == '/')
if ((errno == ENOENT || (errno == ENOTDIR && !(options & FILE_DIRECTORY_FILE))) && name[strlen(name) - 1] == '/')
set_error( STATUS_OBJECT_NAME_INVALID );
else
file_set_error();