Commit 91ff09b6 authored by Maxime Bellengé's avatar Maxime Bellengé Committed by Alexandre Julliard

In case of failure and OF_EXIST is specified, return FALSE instead of

HFILE_ERROR.
parent 8e1fa187
......@@ -2071,5 +2071,8 @@ HFILE WINAPI OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT mode )
error: /* We get here if there was an error opening the file */
ofs->nErrCode = GetLastError();
WARN("(%s): return = HFILE_ERROR error= %d\n", name,ofs->nErrCode );
return HFILE_ERROR;
if (mode & OF_EXIST)
return FALSE;
else
return HFILE_ERROR;
}
......@@ -1390,6 +1390,30 @@ static void test_read_write(void)
ok( ret, "DeleteFileA: error %ld\n", GetLastError());
}
static void test_OpenFile_exists(void)
{
HFILE hFile;
OFSTRUCT ofs;
static const char *file = "\\winver.exe";
char buff[MAX_PATH];
UINT length;
length = GetSystemDirectoryA(buff, MAX_PATH);
if ((length + lstrlen(file) < MAX_PATH))
{
lstrcat(buff, file);
hFile = OpenFile(buff, &ofs, OF_EXIST);
ok( hFile == TRUE, "%s not found : %ld\n", buff, GetLastError());
}
hFile = OpenFile(".\\foo-bar-foo.baz", &ofs, OF_EXIST);
ok( hFile == FALSE, "hFile != FALSE : %ld\n", GetLastError());
}
START_TEST(file)
{
test__hread( );
......@@ -1418,4 +1442,5 @@ START_TEST(file)
test_GetFileType();
test_async_file_errors();
test_read_write();
test_OpenFile_exists();
}
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