d3dcompiler: Implement D3DWriteBlobToFile().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
edd9d23ee1
commit
d12d6b2978
|
@ -514,9 +514,28 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob* blob, const WCHAR *filename, BOOL overwrite)
|
||||
HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob *blob, const WCHAR *filename, BOOL overwrite)
|
||||
{
|
||||
FIXME("blob %p, filename %s, overwrite %d\n", blob, debugstr_w(filename), overwrite);
|
||||
DWORD written_size;
|
||||
SIZE_T data_size;
|
||||
HANDLE file;
|
||||
BOOL ret;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("blob %p, filename %s, overwrite %#x.\n", blob, debugstr_w(filename), overwrite);
|
||||
|
||||
file = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, overwrite ? CREATE_ALWAYS : CREATE_NEW,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
data_size = ID3D10Blob_GetBufferSize(blob);
|
||||
ret = WriteFile(file, ID3D10Blob_GetBufferPointer(blob), data_size, &written_size, NULL);
|
||||
CloseHandle(file);
|
||||
if (!ret || data_size != written_size)
|
||||
{
|
||||
WARN("Failed to write blob contents.\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -859,6 +859,37 @@ static void test_D3DReadFileToBlob(void)
|
|||
DeleteFileW(filename);
|
||||
ID3D10Blob_Release(blob);
|
||||
}
|
||||
|
||||
static void test_D3DWriteBlobToFile(void)
|
||||
{
|
||||
WCHAR temp_dir[MAX_PATH], filename[MAX_PATH];
|
||||
ID3DBlob *blob;
|
||||
HRESULT hr;
|
||||
|
||||
GetTempPathW(ARRAY_SIZE(temp_dir), temp_dir);
|
||||
GetTempFileNameW(temp_dir, NULL, 0, filename);
|
||||
|
||||
hr = D3DCreateBlob(16, &blob);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = D3DWriteBlobToFile(blob, filename, FALSE);
|
||||
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = D3DWriteBlobToFile(blob, filename, TRUE);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
DeleteFileW(filename);
|
||||
|
||||
hr = D3DWriteBlobToFile(blob, filename, FALSE);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = D3DWriteBlobToFile(blob, filename, FALSE);
|
||||
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr);
|
||||
|
||||
DeleteFileW(filename);
|
||||
|
||||
ID3D10Blob_Release(blob);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -870,6 +901,7 @@ START_TEST(blob)
|
|||
test_get_blob_part2();
|
||||
#if D3D_COMPILER_VERSION >= 46
|
||||
test_D3DReadFileToBlob();
|
||||
test_D3DWriteBlobToFile();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue