From 12812772a0cbe143ca89844904198806dfca62a6 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 22 Mar 2019 09:15:18 +0300 Subject: [PATCH] mfplat: Set default attributes for file-based bytestream object. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/mfplat/main.c | 24 ++++++++++++++++++------ dlls/mfplat/tests/mfplat.c | 9 ++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index b3c264b6e0f..12ac940bf01 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -2632,6 +2632,7 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open DWORD filesharemode = FILE_SHARE_READ; DWORD filecreation_disposition = 0; DWORD fileattributes = 0; + FILETIME writetime; HANDLE file; HRESULT hr; @@ -2680,15 +2681,16 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open if(file == INVALID_HANDLE_VALUE) return HRESULT_FROM_WIN32(GetLastError()); - /* Close the file again, since we don't do anything with it yet */ - CloseHandle(file); - object = heap_alloc_zero(sizeof(*object)); if (!object) - return E_OUTOFMEMORY; - - if (FAILED(hr = init_attributes_object(&object->attributes, 0))) { + CloseHandle(file); + return E_OUTOFMEMORY; + } + + if (FAILED(hr = init_attributes_object(&object->attributes, 2))) + { + CloseHandle(file); heap_free(object); return hr; } @@ -2699,8 +2701,18 @@ HRESULT WINAPI MFCreateFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE open InitializeCriticalSection(&object->cs); list_init(&object->pending); + if (GetFileTime(file, NULL, NULL, &writetime)) + { + IMFAttributes_SetBlob(&object->attributes.IMFAttributes_iface, &MF_BYTESTREAM_LAST_MODIFIED_TIME, + (const UINT8 *)&writetime, sizeof(writetime)); + } + + IMFAttributes_SetString(&object->attributes.IMFAttributes_iface, &MF_BYTESTREAM_ORIGIN_NAME, url); + *bytestream = &object->IMFByteStream_iface; + CloseHandle(file); + return S_OK; } diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 6603808e8b7..4e01abf6dc2 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -1169,24 +1169,19 @@ todo_wine hr = IMFAttributes_GetCount(attributes, &count); ok(hr == S_OK, "Failed to get attributes count, hr %#x.\n", hr); -todo_wine ok(count == 2, "Unexpected attributes count %u.\n", count); /* Original file name. */ hr = IMFAttributes_GetAllocatedString(attributes, &MF_BYTESTREAM_ORIGIN_NAME, &str, &count); -todo_wine ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr); -if (SUCCEEDED(hr)) -{ ok(!lstrcmpW(str, filename), "Unexpected name %s.\n", wine_dbgstr_w(str)); CoTaskMemFree(str); -} + /* Modification time. */ hr = IMFAttributes_GetItemType(attributes, &MF_BYTESTREAM_LAST_MODIFIED_TIME, &item_type); -todo_wine { ok(hr == S_OK, "Failed to get item type, hr %#x.\n", hr); ok(item_type == MF_ATTRIBUTE_BLOB, "Unexpected item type.\n"); -} + IMFAttributes_Release(attributes); hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST,