| 94 | } |
| 95 | |
| 96 | HRESULT IStream_WriteToFile(IStream *pStream, const String& filename) |
| 97 | { |
| 98 | unique_handle hFile(CreateFile(filename.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr)); |
| 99 | if (hFile.get() == INVALID_HANDLE_VALUE) |
| 100 | return E_FAIL; |
| 101 | for (;;) |
| 102 | { |
| 103 | char buf[65536]; |
| 104 | DWORD dwWritten; |
| 105 | ULONG size = 0; |
| 106 | HRESULT hr = pStream->Read(buf, sizeof(buf), &size); |
| 107 | if (FAILED(hr)) |
| 108 | return hr; |
| 109 | if (size == 0) |
| 110 | break; |
| 111 | WriteFile(hFile.get(), buf, size, &dwWritten, nullptr); |
| 112 | } |
| 113 | return S_OK; |
| 114 | } |
| 115 | |
| 116 | HRESULT HGLOBAL_WriteToFile(HGLOBAL hGlobal, const String& filename) |
| 117 | { |
no test coverage detected