| 248 | } |
| 249 | |
| 250 | HRESULT GetFileItemsFromIDataObject_FileDescriptor(IDataObject *pDataObj, std::vector<String>& root_files) |
| 251 | { |
| 252 | String tmpdir = env::GetTempChildPath(); |
| 253 | FORMATETC fmtetc_filedescriptor = { static_cast<WORD>(RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR)), nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; |
| 254 | STGMEDIUM medium = { 0 }; |
| 255 | HRESULT hr; |
| 256 | if ((hr = pDataObj->GetData(&fmtetc_filedescriptor, &medium)) == S_OK) |
| 257 | { |
| 258 | FILEGROUPDESCRIPTOR *file_group_descriptor = (FILEGROUPDESCRIPTOR *)GlobalLock(medium.hGlobal); |
| 259 | if (file_group_descriptor) |
| 260 | { |
| 261 | for (unsigned i = 0; i < file_group_descriptor->cItems; ++i) |
| 262 | { |
| 263 | String filename = file_group_descriptor->fgd[i].cFileName; |
| 264 | String filepath = paths::ConcatPath(tmpdir, filename); |
| 265 | if (file_group_descriptor->fgd[i].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| 266 | paths::CreateIfNeeded(filepath); |
| 267 | else |
| 268 | { |
| 269 | ExtractFileItemFromIDataObject_FileContents(pDataObj, i, filepath); |
| 270 | if (file_group_descriptor->fgd[i].dwFlags & FD_WRITESTIME) |
| 271 | SetFileWriteTime(filepath, file_group_descriptor->fgd[i].ftLastWriteTime); |
| 272 | } |
| 273 | if (filename.find('\\') == String::npos) |
| 274 | root_files.push_back(filepath); |
| 275 | } |
| 276 | GlobalUnlock(medium.hGlobal); |
| 277 | } |
| 278 | ReleaseStgMedium(&medium); |
| 279 | } |
| 280 | return hr; |
| 281 | } |
| 282 | |
| 283 | } |
| 284 |
no test coverage detected