MCPcopy Create free account
hub / github.com/WinMerge/winmerge / IStream_WriteToFile

Function IStream_WriteToFile

Src/DropHandler.cpp:96–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Calls 3

WriteFileFunction · 0.85
getMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected