Skip to content

Commit

Permalink
kernel32/tests: Test error code when FindFirstFileA uses file as dire…
Browse files Browse the repository at this point in the history
…ctory.
  • Loading branch information
Brendan McGrath authored and julliard committed Jun 5, 2024
1 parent 9ec5011 commit 34446f8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dlls/kernel32/tests/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,7 @@ static void test_FindFirstFileA(void)
char buffer[5] = "C:\\";
char buffer2[100];
char nonexistent[MAX_PATH];
BOOL found = FALSE;

/* try FindFirstFileA on "C:\" */
buffer[0] = get_windows_drive();
Expand Down Expand Up @@ -2746,10 +2747,32 @@ static void test_FindFirstFileA(void)
ok( FindNextFileA( handle, &data ), "FindNextFile failed\n" );
ok( !strcmp( data.cFileName, ".." ), "FindNextFile should return '..' as second entry\n" );
while (FindNextFileA( handle, &data ))
{
ok ( strcmp( data.cFileName, "." ) && strcmp( data.cFileName, ".." ),
"FindNextFile shouldn't return '%s'\n", data.cFileName );
if (!found && (data.dwFileAttributes == FILE_ATTRIBUTE_NORMAL ||
data.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE))
{
GetWindowsDirectoryA( buffer2, sizeof(buffer2) );
strcat(buffer2, "\\");
strcat(buffer2, data.cFileName);
strcat(buffer2, "\\*");
found = TRUE;
}
}
ok ( FindClose(handle) == TRUE, "Failed to close handle %s\n", buffer2 );

ok ( found, "Windows dir should not be empty\n" );
if (found)
{
SetLastError( 0xdeadbeef );
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 );
}

/* try FindFirstFileA on "C:\foo\" */
SetLastError( 0xdeadbeaf );
if (!GetTempFileNameA( buffer, "foo", 0, nonexistent ))
Expand Down

0 comments on commit 34446f8

Please sign in to comment.