MCPcopy Create free account
hub / github.com/derceg/explorerplusplus / CopyDroppedFilesInternalAsync

Function CopyDroppedFilesInternalAsync

Explorer++/Helper/DropHandler.cpp:1117–1198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115}
1116
1117BOOL CopyDroppedFilesInternalAsync(PastedFilesInfo_t *ppfi)
1118{
1119 TCHAR *pszFullFilenames = NFileOperations::BuildFilenameList(ppfi->FullFilenameList);
1120
1121 UINT wFunc = 0;
1122
1123 if(ppfi->bCopy)
1124 {
1125 wFunc = FO_COPY;
1126 }
1127 else
1128 {
1129 wFunc = FO_MOVE;
1130 }
1131
1132 FILEOP_FLAGS fFlags = FOF_WANTMAPPINGHANDLE;
1133
1134 if(ppfi->bRenameOnCollision)
1135 {
1136 fFlags |= FOF_RENAMEONCOLLISION;
1137 }
1138
1139 SHFILEOPSTRUCT shfo;
1140 shfo.hwnd = ppfi->hwnd;
1141 shfo.wFunc = wFunc;
1142 shfo.pFrom = pszFullFilenames;
1143 shfo.pTo = ppfi->strDestDirectory.c_str();
1144 shfo.fFlags = fFlags;
1145 BOOL bRes = (!SHFileOperation(&shfo) && !shfo.fAnyOperationsAborted);
1146
1147 free(pszFullFilenames);
1148
1149 if(bRes)
1150 {
1151 std::list<std::wstring> filenameList;
1152
1153 for(const auto &fullFilename : ppfi->FullFilenameList)
1154 {
1155 TCHAR szFilename[MAX_PATH];
1156 StringCchCopy(szFilename,SIZEOF_ARRAY(szFilename),fullFilename.c_str());
1157 PathStripPath(szFilename);
1158
1159 filenameList.emplace_back(szFilename);
1160 }
1161
1162 if(shfo.hNameMappings != NULL)
1163 {
1164 auto *phtm = reinterpret_cast<HANDLETOMAPPINGS *>(shfo.hNameMappings);
1165
1166 for(int i = 0;i < static_cast<int>(phtm->uNumberOfMappings);i++)
1167 {
1168 for(auto itr = filenameList.begin();itr != filenameList.end();itr++)
1169 {
1170 TCHAR szOldFileName[MAX_PATH];
1171 StringCchCopy(szOldFileName,SIZEOF_ARRAY(szOldFileName),
1172 phtm->lpSHNameMapping[i].pszOldPath);
1173 PathStripPath(szOldFileName);
1174

Callers 2

Calls 4

c_strMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
OnDropFileMethod · 0.45

Tested by

no test coverage detected