Ticket #2989: svndiff.txt

File svndiff.txt, 5.4 KB (added by Luc, 8 years ago)
Line 
1Index: filezilla-forsvn/src/interface/resources/menus.xrc
2===================================================================
3--- filezilla-forsvn/src/interface/resources/menus.xrc (revision 4782)
4+++ filezilla-forsvn/src/interface/resources/menus.xrc (working copy)
5@@ -299,6 +299,10 @@
6 <label>&amp;Create directory</label>
7 <help>Create a new subdirectory in the current directory</help>
8 </object>
9+ <object class="wxMenuItem" name="ID_NEW_FILE">
10+ <label>Crea&amp;te new file</label>
11+ <help>Create a new, empty file in the current directory</help>
12+ </object>
13 <object class="wxMenuItem" name="ID_CONTEXT_REFRESH">
14 <label>Re&amp;fresh</label>
15 </object>
16Index: filezilla-forsvn/src/interface/RemoteListView.cpp
17===================================================================
18--- filezilla-forsvn/src/interface/RemoteListView.cpp (revision 4782)
19+++ filezilla-forsvn/src/interface/RemoteListView.cpp (working copy)
20@@ -338,6 +338,7 @@
21 EVT_MENU(XRCID("ID_DOWNLOAD"), CRemoteListView::OnMenuDownload)
22 EVT_MENU(XRCID("ID_ADDTOQUEUE"), CRemoteListView::OnMenuDownload)
23 EVT_MENU(XRCID("ID_MKDIR"), CRemoteListView::OnMenuMkdir)
24+ EVT_MENU(XRCID("ID_NEW_FILE"), CRemoteListView::OnMenuNewfile)
25 EVT_MENU(XRCID("ID_DELETE"), CRemoteListView::OnMenuDelete)
26 EVT_MENU(XRCID("ID_RENAME"), CRemoteListView::OnMenuRename)
27 EVT_MENU(XRCID("ID_CHMOD"), CRemoteListView::OnMenuChmod)
28@@ -1402,7 +1403,7 @@
29 wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_REMOTEFILELIST"));
30 if (!pMenu)
31 return;
32-
33+
34 if (!m_pState->IsRemoteConnected() || !m_pState->IsRemoteIdle())
35 {
36 pMenu->Delete(XRCID("ID_ENTER"));
37@@ -1415,6 +1416,7 @@
38 pMenu->Enable(XRCID("ID_EDIT"), false);
39 pMenu->Enable(XRCID("ID_GETURL"), false);
40 pMenu->Enable(XRCID("ID_CONTEXT_REFRESH"), false);
41+ pMenu->Enable(XRCID("ID_NEW_FILE"), false);
42 }
43 else if ((GetItemCount() && GetItemState(0, wxLIST_STATE_SELECTED)))
44 {
45@@ -1425,6 +1427,7 @@
46 pMenu->Enable(XRCID("ID_CHMOD"), false);
47 pMenu->Enable(XRCID("ID_EDIT"), false);
48 pMenu->Enable(XRCID("ID_GETURL"), false);
49+ pMenu->Delete(XRCID("ID_NEW_FILE"));
50 }
51 else if (GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) == -1)
52 {
53@@ -1467,9 +1470,10 @@
54 pMenu->Enable(XRCID("ID_CHMOD"), false);
55 pMenu->Enable(XRCID("ID_EDIT"), false);
56 pMenu->Enable(XRCID("ID_GETURL"), false);
57+ pMenu->Enable(XRCID("ID_NEW_FILE"), true);
58 }
59 else
60- {
61+ {
62 if (selectedDir)
63 pMenu->Enable(XRCID("ID_EDIT"), false);
64 else
65@@ -3148,3 +3152,69 @@
66 m_pState->ChangeRemoteDir(m_pDirectoryListing->path, _T(".."));
67 }
68 }
69+
70+void CRemoteListView::OnMenuNewfile(wxCommandEvent& event)
71+{
72+ CInputDialog dlg;
73+ if (!dlg.Create(this, _("Create empty file"), _("Please enter the name of the file which should be created:")))
74+ return;
75+
76+ if (dlg.ShowModal() != wxID_OK)
77+ return;
78+
79+ if (dlg.GetValue() == _T(""))
80+ {
81+ wxBell();
82+ return;
83+ }
84+
85+ wxString newFileName = dlg.GetValue();
86+
87+ // Copied from elsewhere in the source, checks for characters that Windows deems invalid
88+ if ((newFileName.Find('/') != -1) ||
89+ (newFileName.Find('\\') != -1) ||
90+ (newFileName.Find(':') != -1) ||
91+ (newFileName.Find('*') != -1) ||
92+ (newFileName.Find('?') != -1) ||
93+ (newFileName.Find('"') != -1) ||
94+ (newFileName.Find('<') != -1) ||
95+ (newFileName.Find('>') != -1) ||
96+ (newFileName.Find('|') != -1))
97+ {
98+ wxMessageBox(_("Filename may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
99+ return;
100+ }
101+
102+ // Check if target file already exists
103+ for (unsigned int i = 0; i < m_pDirectoryListing->GetCount(); i++)
104+ {
105+ if (newFileName == (*m_pDirectoryListing)[i].name)
106+ {
107+ wxMessageBox(_("Target filename already exists!"));
108+ return;
109+ }
110+ }
111+
112+ CEditHandler* edithandler = CEditHandler::Get(); // Used to get the temporary folder
113+
114+ wxString emptyfile_name = _T("empty_file_yq744zm");
115+ wxString emptyfile_path = edithandler->GetLocalDirectory();
116+ wxString emptyfile = emptyfile_path + emptyfile_name;
117+
118+ // Create the empty temporary file
119+ wxFile file;
120+ file.Create(emptyfile);
121+
122+ const CServer* pServer = m_pState->GetServer();
123+ if (!pServer)
124+ {
125+ wxBell();
126+ return;
127+ }
128+
129+ CLocalPath localPath(emptyfile_path, &emptyfile_name);
130+
131+ m_pQueue->QueueFile(false, false, emptyfile_name, newFileName, localPath, m_pDirectoryListing->path, *pServer, 0);
132+ m_pQueue->QueueFile_Finish(true);
133+}
134Index: filezilla-forsvn/src/interface/RemoteListView.h
135===================================================================
136--- filezilla-forsvn/src/interface/RemoteListView.h (revision 4782)
137+++ filezilla-forsvn/src/interface/RemoteListView.h (working copy)
138@@ -115,6 +115,7 @@
139 void OnMenuEnter(wxCommandEvent& event);
140 void OnMenuGeturl(wxCommandEvent& event);
141 void OnMenuRefresh(wxCommandEvent& event);
142+ void OnMenuNewfile(wxCommandEvent& event);
143 };
144
145 #endif
146Index: filezilla-forsvn/src/interface/edithandler.cpp
147===================================================================
148--- filezilla-forsvn/src/interface/edithandler.cpp (revision 4782)
149+++ filezilla-forsvn/src/interface/edithandler.cpp (working copy)
150@@ -204,7 +204,10 @@
151 if (m_lockfile_descriptor >= 0)
152 close(m_lockfile_descriptor);
153 #endif
154-
155+
156+ if (wxFileExists(m_localDir + _T("empty_file_yq744zm")))
157+ wxRemoveFile(m_localDir + _T("empty_file_yq744zm"));
158+
159 RemoveAll(true);
160 wxRmdir(m_localDir);
161 }