MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / Execute

Method Execute

src/TortoiseProc/Commands/DropCopyCommand.cpp:28–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "ShellUpdater.h"
27
28bool DropCopyCommand::Execute()
29{
30 CString sDroppath = parser.GetVal(L"droptarget");
31 if (CTGitPath(sDroppath).IsAdminDir())
32 {
33 MessageBox(GetExplorerHWND(), L"Can't drop to .git repository directory\n", L"TortoiseGit", MB_OK | MB_ICONERROR);
34 return FALSE;
35 }
36 unsigned long count = 0;
37
38 CString sNewName;
39 pathList.RemoveAdminPaths();
40 if (parser.HasKey(L"rename") && pathList.GetCount() == 1)
41 {
42 // ask for a new name of the source item
43 CRenameDlg renDlg;
44 renDlg.SetInputValidator([&](const int /*nID*/, const CString& input) -> CString
45 {
46 if (PathFileExists(sDroppath + L'\\' + input))
47 return CString(static_cast<LPCWSTR>(CFormatMessageWrapper(ERROR_FILE_EXISTS)));
48
49 return{};
50 });
51 renDlg.m_sBaseDir = sDroppath;
52 renDlg.m_windowtitle.LoadString(IDS_PROC_COPYRENAME);
53 renDlg.m_name = pathList[0].GetFileOrDirectoryName();
54 if (renDlg.DoModal() != IDOK)
55 return FALSE;
56 sNewName = renDlg.m_name;
57 }
58 CSysProgressDlg progress;
59 progress.SetTitle(IDS_PROC_COPYING);
60 progress.SetTime(true);
61 progress.ShowModeless(CWnd::FromHandle(GetExplorerHWND()));
62 for (int nPath = 0; nPath < pathList.GetCount(); ++nPath)
63 {
64 const CTGitPath& sourcePath = orgPathList[nPath];
65
66 CTGitPath fullDropPath(sDroppath);
67
68 if (sNewName.IsEmpty())
69 fullDropPath.AppendPathString(sourcePath.GetFileOrDirectoryName());
70 else
71 fullDropPath.AppendPathString(sNewName);
72
73 // Check for a drop-on-to-ourselves
74 if (sourcePath.IsEquivalentTo(fullDropPath))
75 {
76 // Offer a rename
77 progress.Stop();
78 CRenameDlg dlg;
79 dlg.SetInputValidator([&](const int /*nID*/, const CString& input) -> CString
80 {
81 CTGitPath newPath(sDroppath);
82 newPath.AppendPathString(input);
83 if (newPath.Exists())
84 return CString(static_cast<LPCWSTR>(CFormatMessageWrapper(ERROR_FILE_EXISTS)));
85

Callers

nothing calls this directly

Calls 15

GetExplorerHWNDFunction · 0.85
CStringClass · 0.85
GetValMethod · 0.80
IsAdminDirMethod · 0.80
RemoveAdminPathsMethod · 0.80
HasKeyMethod · 0.80
SetInputValidatorMethod · 0.80
ShowModelessMethod · 0.80
AppendPathStringMethod · 0.80
IsEquivalentToMethod · 0.80

Tested by

no test coverage detected