1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "DropCopyAddCommand.h"
\r
22 #include "SVNProgressDlg.h"
\r
23 #include "MessageBox.h"
\r
25 bool DropCopyAddCommand::Execute()
\r
28 CString droppath = parser.GetVal(_T("droptarget"));
\r
29 if (CTSVNPath(droppath).IsAdminDir())
\r
32 pathList.RemoveAdminPaths();
\r
33 CTSVNPathList copiedFiles;
\r
34 for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
\r
36 if (!pathList[nPath].IsEquivalentTo(CTSVNPath(droppath)))
\r
38 //copy the file to the new location
\r
39 CString name = pathList[nPath].GetFileOrDirectoryName();
\r
40 if (::PathFileExists(droppath+_T("\\")+name))
\r
43 strMessage.Format(IDS_PROC_OVERWRITE_CONFIRM, (LPCTSTR)(droppath+_T("\\")+name));
\r
44 int ret = CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_YESNOCANCEL | MB_ICONQUESTION);
\r
47 if (!::CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))
\r
49 //the copy operation failed! Get out of here!
\r
51 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
\r
52 FORMAT_MESSAGE_FROM_SYSTEM |
\r
53 FORMAT_MESSAGE_IGNORE_INSERTS,
\r
56 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
\r
62 strMessage.Format(IDS_ERR_COPYFILES, (LPTSTR)lpMsgBuf);
\r
63 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);
\r
64 LocalFree( lpMsgBuf );
\r
68 if (ret == IDCANCEL)
\r
70 return FALSE; //cancel the whole operation
\r
73 else if (!CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))
\r
75 //the copy operation failed! Get out of here!
\r
77 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
\r
78 FORMAT_MESSAGE_FROM_SYSTEM |
\r
79 FORMAT_MESSAGE_IGNORE_INSERTS,
\r
82 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
\r
88 strMessage.Format(IDS_ERR_COPYFILES, lpMsgBuf);
\r
89 CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseSVN"), MB_OK | MB_ICONINFORMATION);
\r
90 LocalFree( lpMsgBuf );
\r
93 copiedFiles.AddPath(CTSVNPath(droppath+_T("\\")+name)); //add the new filepath
\r
96 //now add all the newly copied files to the working copy
\r
97 CSVNProgressDlg progDlg;
\r
98 theApp.m_pMainWnd = &progDlg;
\r
99 progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Add);
\r
100 if (parser.HasVal(_T("closeonend")))
\r
101 progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));
\r
102 progDlg.SetPathList(copiedFiles);
\r
103 ProjectProperties props;
\r
104 props.ReadPropsPathList(copiedFiles);
\r
105 progDlg.SetProjectProperties(props);
\r
107 bRet = !progDlg.DidErrorsOccur();
\r