Index: filezilla-forsvn/src/interface/resources/menus.xrc =================================================================== --- filezilla-forsvn/src/interface/resources/menus.xrc (revision 4782) +++ filezilla-forsvn/src/interface/resources/menus.xrc (working copy) @@ -299,6 +299,10 @@ Create a new subdirectory in the current directory + + + Create a new, empty file in the current directory + Index: filezilla-forsvn/src/interface/RemoteListView.cpp =================================================================== --- filezilla-forsvn/src/interface/RemoteListView.cpp (revision 4782) +++ filezilla-forsvn/src/interface/RemoteListView.cpp (working copy) @@ -338,6 +338,7 @@ EVT_MENU(XRCID("ID_DOWNLOAD"), CRemoteListView::OnMenuDownload) EVT_MENU(XRCID("ID_ADDTOQUEUE"), CRemoteListView::OnMenuDownload) EVT_MENU(XRCID("ID_MKDIR"), CRemoteListView::OnMenuMkdir) + EVT_MENU(XRCID("ID_NEW_FILE"), CRemoteListView::OnMenuNewfile) EVT_MENU(XRCID("ID_DELETE"), CRemoteListView::OnMenuDelete) EVT_MENU(XRCID("ID_RENAME"), CRemoteListView::OnMenuRename) EVT_MENU(XRCID("ID_CHMOD"), CRemoteListView::OnMenuChmod) @@ -1402,7 +1403,7 @@ wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_REMOTEFILELIST")); if (!pMenu) return; - + if (!m_pState->IsRemoteConnected() || !m_pState->IsRemoteIdle()) { pMenu->Delete(XRCID("ID_ENTER")); @@ -1415,6 +1416,7 @@ pMenu->Enable(XRCID("ID_EDIT"), false); pMenu->Enable(XRCID("ID_GETURL"), false); pMenu->Enable(XRCID("ID_CONTEXT_REFRESH"), false); + pMenu->Enable(XRCID("ID_NEW_FILE"), false); } else if ((GetItemCount() && GetItemState(0, wxLIST_STATE_SELECTED))) { @@ -1425,6 +1427,7 @@ pMenu->Enable(XRCID("ID_CHMOD"), false); pMenu->Enable(XRCID("ID_EDIT"), false); pMenu->Enable(XRCID("ID_GETURL"), false); + pMenu->Delete(XRCID("ID_NEW_FILE")); } else if (GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) == -1) { @@ -1467,9 +1470,10 @@ pMenu->Enable(XRCID("ID_CHMOD"), false); pMenu->Enable(XRCID("ID_EDIT"), false); pMenu->Enable(XRCID("ID_GETURL"), false); + pMenu->Enable(XRCID("ID_NEW_FILE"), true); } else - { + { if (selectedDir) pMenu->Enable(XRCID("ID_EDIT"), false); else @@ -3148,3 +3152,69 @@ m_pState->ChangeRemoteDir(m_pDirectoryListing->path, _T("..")); } } + +void CRemoteListView::OnMenuNewfile(wxCommandEvent& event) +{ + CInputDialog dlg; + if (!dlg.Create(this, _("Create empty file"), _("Please enter the name of the file which should be created:"))) + return; + + if (dlg.ShowModal() != wxID_OK) + return; + + if (dlg.GetValue() == _T("")) + { + wxBell(); + return; + } + + wxString newFileName = dlg.GetValue(); + + // Copied from elsewhere in the source, checks for characters that Windows deems invalid + if ((newFileName.Find('/') != -1) || + (newFileName.Find('\\') != -1) || + (newFileName.Find(':') != -1) || + (newFileName.Find('*') != -1) || + (newFileName.Find('?') != -1) || + (newFileName.Find('"') != -1) || + (newFileName.Find('<') != -1) || + (newFileName.Find('>') != -1) || + (newFileName.Find('|') != -1)) + { + wxMessageBox(_("Filename may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION); + return; + } + + // Check if target file already exists + for (unsigned int i = 0; i < m_pDirectoryListing->GetCount(); i++) + { + if (newFileName == (*m_pDirectoryListing)[i].name) + { + wxMessageBox(_("Target filename already exists!")); + return; + } + } + + CEditHandler* edithandler = CEditHandler::Get(); // Used to get the temporary folder + + wxString emptyfile_name = _T("empty_file_yq744zm"); + wxString emptyfile_path = edithandler->GetLocalDirectory(); + wxString emptyfile = emptyfile_path + emptyfile_name; + + // Create the empty temporary file + wxFile file; + file.Create(emptyfile); + + const CServer* pServer = m_pState->GetServer(); + if (!pServer) + { + wxBell(); + return; + } + + CLocalPath localPath(emptyfile_path, &emptyfile_name); + + m_pQueue->QueueFile(false, false, emptyfile_name, newFileName, localPath, m_pDirectoryListing->path, *pServer, 0); + m_pQueue->QueueFile_Finish(true); +} Index: filezilla-forsvn/src/interface/RemoteListView.h =================================================================== --- filezilla-forsvn/src/interface/RemoteListView.h (revision 4782) +++ filezilla-forsvn/src/interface/RemoteListView.h (working copy) @@ -115,6 +115,7 @@ void OnMenuEnter(wxCommandEvent& event); void OnMenuGeturl(wxCommandEvent& event); void OnMenuRefresh(wxCommandEvent& event); + void OnMenuNewfile(wxCommandEvent& event); }; #endif Index: filezilla-forsvn/src/interface/edithandler.cpp =================================================================== --- filezilla-forsvn/src/interface/edithandler.cpp (revision 4782) +++ filezilla-forsvn/src/interface/edithandler.cpp (working copy) @@ -204,7 +204,10 @@ if (m_lockfile_descriptor >= 0) close(m_lockfile_descriptor); #endif - + + if (wxFileExists(m_localDir + _T("empty_file_yq744zm"))) + wxRemoveFile(m_localDir + _T("empty_file_yq744zm")); + RemoveAll(true); wxRmdir(m_localDir); }