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

Method CopyDroppedFiles

Explorer++/Helper/DropHandler.cpp:897–961  ·  view source on GitHub ↗

Loop through each of the dropped files. Add them to the list of files that are to be copied. Then, copy the files themselves in a separate background thread, update the filename list if any files were renamed (due to a collision), and then send the list back to the caller. Differences between drag and drop/paste: - Effect may already be specified on paste. - No drop point used when pas

Source from the content-addressed store, hash-verified

895 - No drop point used when pasting files.
896*/
897void DropHandler::CopyDroppedFiles(const HDROP &hd,BOOL bPreferredEffect,DWORD dwPreferredEffect)
898{
899 std::list<std::wstring> copyFilenameList;
900 std::list<std::wstring> moveFilenameList;
901
902 BOOL bRenameOnCollision = m_bRenameOnCollision;
903
904 int nDroppedFiles = DragQueryFile(hd,0xFFFFFFFF,NULL,NULL);
905
906 for(int i = 0;i < nDroppedFiles;i++)
907 {
908 TCHAR szFullFileName[MAX_PATH];
909 DragQueryFile(hd,i,szFullFileName,SIZEOF_ARRAY(szFullFileName));
910
911 TCHAR szSourceDirectory[MAX_PATH];
912 StringCchCopy(szSourceDirectory,SIZEOF_ARRAY(szSourceDirectory),szFullFileName);
913 PathRemoveFileSpec(szSourceDirectory);
914
915 /* Force files to be renamed when they are copied and pasted
916 in the same directory. */
917 if(lstrcmpi(m_szDestDirectory,szSourceDirectory) == 0)
918 {
919 bRenameOnCollision = TRUE;
920 }
921
922 DWORD dwEffect;
923
924 if(bPreferredEffect)
925 {
926 dwEffect = dwPreferredEffect;
927 }
928 else
929 {
930 BOOL bOnSameDrive;
931
932 /* If no preferred drop effect is specified,
933 decide whether to copy/move files based on their
934 locations. */
935 bOnSameDrive = CheckItemLocations(i);
936
937 dwEffect = DetermineDragEffect(m_grfKeyState,
938 m_dwEffect,TRUE,bOnSameDrive);
939 }
940
941 TCHAR szFileName[MAX_PATH];
942 StringCchCopy(szFileName,SIZEOF_ARRAY(szFileName),szFullFileName);
943 PathStripPath(szFileName);
944
945 if(dwEffect & DROPEFFECT_MOVE)
946 {
947 moveFilenameList.emplace_back(szFullFileName);
948 }
949 else if(dwEffect & DROPEFFECT_COPY)
950 {
951 copyFilenameList.emplace_back(szFullFileName);
952 }
953 else if(dwEffect & DROPEFFECT_LINK)
954 {

Callers

nothing calls this directly

Calls 1

DetermineDragEffectFunction · 0.85

Tested by

no test coverage detected