| 12 | } |
| 13 | |
| 14 | bool COMApiTest::Run(std::vector<TestOperation> const& paths) |
| 15 | { |
| 16 | return std::all_of( |
| 17 | std::execution::par_unseq, |
| 18 | std::begin(paths), |
| 19 | std::end(paths), |
| 20 | [](TestOperation const& test) |
| 21 | { |
| 22 | COMInitializeHelper s_helper; |
| 23 | wil::com_ptr<IFileOperation> pfo; |
| 24 | auto hr = CoCreateInstance(CLSID_FileOperation, NULL, CLSCTX_ALL, IID_PPV_ARGS(pfo.put())); |
| 25 | if (!SUCCEEDED(hr)) |
| 26 | return false; |
| 27 | |
| 28 | if (!SUCCEEDED(pfo->SetOperationFlags(FOF_NO_UI))) |
| 29 | return false; |
| 30 | |
| 31 | wil::com_ptr<IShellItem> psiFrom, psiDest; |
| 32 | if(!SUCCEEDED(SHCreateItemFromParsingName(test.source.data(), NULL, IID_PPV_ARGS(psiFrom.put())))) |
| 33 | return false; |
| 34 | |
| 35 | if (!SUCCEEDED(SHCreateItemFromParsingName(test.destination.data(), NULL, IID_PPV_ARGS(psiDest.put())))) |
| 36 | return false; |
| 37 | |
| 38 | |
| 39 | //if (!SUCCEEDED(pfo->CopyItem(psiFrom.get(), psiDest.get(), nullptr, nullptr))) |
| 40 | // return false; |
| 41 | switch (test.operation) |
| 42 | { |
| 43 | case TestOperation::Operation::Copy: |
| 44 | if (!SUCCEEDED(pfo->CopyItem(psiFrom.get(), psiDest.get(), nullptr, nullptr))) |
| 45 | return false; |
| 46 | case TestOperation::Operation::Move: |
| 47 | if (!SUCCEEDED(pfo->MoveItem(psiFrom.get(), psiDest.get(), nullptr, nullptr))) |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | if (!SUCCEEDED(pfo->PerformOperations())) |
| 53 | return false; |
| 54 | |
| 55 | return true; |
| 56 | } |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | std::string COMApiTest::GetName() const |
| 61 | { |