winmm: Search the default path when opening an existing file in create_file_OF().

Based on a patch by Alistair Leslie-Hughes.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49650
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-12-17 16:40:51 -06:00 committed by Alexandre Julliard
parent 2df4112661
commit 1d043f4da7
2 changed files with 9 additions and 2 deletions

View File

@ -52,6 +52,7 @@ static WINE_MMIO *MMIOList;
static HANDLE create_file_OF( LPCSTR path, INT mode )
{
DWORD access, sharing, creation;
char full_path[MAX_PATH];
if (mode & OF_CREATE)
{
@ -79,7 +80,13 @@ static HANDLE create_file_OF( LPCSTR path, INT mode )
case OF_SHARE_COMPAT:
default: sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break;
}
return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
if (mode & OF_CREATE)
return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
if (!SearchPathA( NULL, path, NULL, MAX_PATH, full_path, NULL ))
return INVALID_HANDLE_VALUE;
return CreateFileA( full_path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
}
/**************************************************************************

View File

@ -551,7 +551,7 @@ static void test_mmioOpen_create(void)
wcscpy(buffer, L"test_mmio_path");
hmmio = mmioOpenW(buffer, &info, MMIO_WRITE);
todo_wine ok(!!hmmio, "failed to open file, error %#x\n", info.wErrorRet);
ok(!!hmmio, "failed to open file, error %#x\n", info.wErrorRet);
mmioClose(hmmio, 0);
wcscpy(buffer, L"test_mmio_path");