Commit 2f0febe6 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

ntdll: Ignore positive matches in read_directory_stat() for case-insensitive filesystems.

It's necessary to return the actual filename with correct casing and a plain stat doesn't allow that. Make read_directory_stat() return the result of the stat() call on a case-insensitive filesystem only when the file is missing.
parent 5d65b9d0
......@@ -2065,8 +2065,9 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
int unix_len, ret, used_default;
char *unix_name;
struct stat st;
BOOL case_sensitive = get_dir_case_sensitivity(".");
TRACE("trying optimisation for file %s\n", debugstr_us( mask ));
TRACE("looking up file %s\n", debugstr_us( mask ));
unix_len = ntdll_wcstoumbs( 0, mask->Buffer, mask->Length / sizeof(WCHAR), NULL, 0, NULL, NULL );
if (!(unix_name = RtlAllocateHeap( GetProcessHeap(), 0, unix_len + 1)))
......@@ -2091,7 +2092,7 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
}
ret = stat( unix_name, &st );
if (!ret)
if (case_sensitive && !ret)
{
union file_directory_info *info = append_entry( buffer, io, length, unix_name, NULL, NULL, class );
if (info)
......@@ -2101,6 +2102,19 @@ static int read_directory_stat( int fd, IO_STATUS_BLOCK *io, void *buffer, ULONG
}
else io->u.Status = STATUS_NO_MORE_FILES;
}
else if (!case_sensitive && ret && (errno == ENOENT || errno == ENOTDIR))
{
/* If the file does not exist, return that info.
* If the file DOES exist, return failure and fallback to the next
* read_directory_* function (we need to return the case-preserved
* filename stored on the filesystem). */
ret = 0;
io->u.Status = STATUS_NO_MORE_FILES;
}
else
{
ret = -1;
}
}
else ret = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment