Ticket #2989: diff-rup.patch

File diff-rup.patch, 5.8 KB (added by Luc, 12 years ago)

diff -rup as suggested by @hejazee (comment 26)

  • src/interface/edithandler.cpp

    diff -rup filezilla/src/interface/edithandler.cpp filezilla-new/src/interface/edithandler.cpp
    old new void CEditHandler::Release()  
    204204        if (m_lockfile_descriptor >= 0)
    205205            close(m_lockfile_descriptor);
    206206#endif
    207 
     207       
     208        if (wxFileExists(m_localDir + _T("empty_file_yq744zm")))
     209            wxRemoveFile(m_localDir + _T("empty_file_yq744zm"));
     210       
    208211        RemoveAll(true);
    209212        wxRmdir(m_localDir);
    210213    }
  • src/interface/RemoteListView.cpp

    diff -rup filezilla/src/interface/RemoteListView.cpp filezilla-new/src/interface/RemoteListView.cpp
    old new BEGIN_EVENT_TABLE(CRemoteListView, CFile  
    338338    EVT_MENU(XRCID("ID_DOWNLOAD"), CRemoteListView::OnMenuDownload)
    339339    EVT_MENU(XRCID("ID_ADDTOQUEUE"), CRemoteListView::OnMenuDownload)
    340340    EVT_MENU(XRCID("ID_MKDIR"), CRemoteListView::OnMenuMkdir)
     341    EVT_MENU(XRCID("ID_NEW_FILE"), CRemoteListView::OnMenuNewfile)
    341342    EVT_MENU(XRCID("ID_DELETE"), CRemoteListView::OnMenuDelete)
    342343    EVT_MENU(XRCID("ID_RENAME"), CRemoteListView::OnMenuRename)
    343344    EVT_MENU(XRCID("ID_CHMOD"), CRemoteListView::OnMenuChmod)
    void CRemoteListView::OnContextMenu(wxCo  
    14021403    wxMenu* pMenu = wxXmlResource::Get()->LoadMenu(_T("ID_MENU_REMOTEFILELIST"));
    14031404    if (!pMenu)
    14041405        return;
    1405 
     1406   
    14061407    if (!m_pState->IsRemoteConnected() || !m_pState->IsRemoteIdle())
    14071408    {
    14081409        pMenu->Delete(XRCID("ID_ENTER"));
    void CRemoteListView::OnContextMenu(wxCo  
    14151416        pMenu->Enable(XRCID("ID_EDIT"), false);
    14161417        pMenu->Enable(XRCID("ID_GETURL"), false);
    14171418        pMenu->Enable(XRCID("ID_CONTEXT_REFRESH"), false);
     1419        pMenu->Enable(XRCID("ID_NEW_FILE"), false);
    14181420    }
    14191421    else if ((GetItemCount() && GetItemState(0, wxLIST_STATE_SELECTED)))
    14201422    {
    void CRemoteListView::OnContextMenu(wxCo  
    14251427        pMenu->Enable(XRCID("ID_CHMOD"), false);
    14261428        pMenu->Enable(XRCID("ID_EDIT"), false);
    14271429        pMenu->Enable(XRCID("ID_GETURL"), false);
     1430        pMenu->Delete(XRCID("ID_NEW_FILE"));
    14281431    }
    14291432    else if (GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) == -1)
    14301433    {
    void CRemoteListView::OnContextMenu(wxCo  
    14671470            pMenu->Enable(XRCID("ID_CHMOD"), false);
    14681471            pMenu->Enable(XRCID("ID_EDIT"), false);
    14691472            pMenu->Enable(XRCID("ID_GETURL"), false);
     1473            pMenu->Enable(XRCID("ID_NEW_FILE"), true);
    14701474        }
    14711475        else
    1472         {
     1476        {   
    14731477            if (selectedDir)
    14741478                pMenu->Enable(XRCID("ID_EDIT"), false);
    14751479            else
    void CRemoteListView::OnNavigationEvent(  
    31483152        m_pState->ChangeRemoteDir(m_pDirectoryListing->path, _T(".."));
    31493153    }
    31503154}
     3155
     3156void CRemoteListView::OnMenuNewfile(wxCommandEvent& event)
     3157{
     3158    CInputDialog dlg;
     3159    if (!dlg.Create(this, _("Create empty file"), _("Please enter the name of the file which should be created:")))
     3160        return;
     3161
     3162    if (dlg.ShowModal() != wxID_OK)
     3163        return;
     3164
     3165    if (dlg.GetValue() == _T(""))
     3166    {
     3167        wxBell();
     3168        return;
     3169    }
     3170
     3171    wxString newFileName = dlg.GetValue();
     3172   
     3173    if ((newFileName.Find('/')  != -1) ||
     3174        (newFileName.Find('\\') != -1) ||
     3175        (newFileName.Find(':')  != -1) ||
     3176        (newFileName.Find('*')  != -1) ||
     3177        (newFileName.Find('?')  != -1) ||
     3178        (newFileName.Find('"')  != -1) ||
     3179        (newFileName.Find('<')  != -1) ||
     3180        (newFileName.Find('>')  != -1) ||
     3181        (newFileName.Find('|')  != -1))
     3182    {
     3183        wxMessageBox(_("Filename may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
     3184        return;
     3185    }
     3186
     3187    // Check if target file already exists
     3188    for (unsigned int i = 0; i < m_pDirectoryListing->GetCount(); i++)
     3189    {
     3190        if (newFileName == (*m_pDirectoryListing)[i].name)
     3191        {
     3192            wxMessageBox(_("Target filename already exists!"));
     3193            return;
     3194        }
     3195    }
     3196   
     3197    CEditHandler* edithandler = CEditHandler::Get(); //Used to get the temporary folder
     3198   
     3199    wxString emptyfile_name = _T("empty_file_yq744zm");
     3200    wxString emptyfile_path = edithandler->GetLocalDirectory();
     3201   
     3202    wxString emptyfile = emptyfile_path.Append(emptyfile_name);
     3203    fclose(fopen((const char*)emptyfile.mb_str(wxConvUTF8), "w")); // Create the empty file
     3204   
     3205    const CServer* pServer = m_pState->GetServer();
     3206    if (!pServer)
     3207    {
     3208        wxBell();
     3209        return;
     3210    }
     3211   
     3212    CLocalPath localPath(emptyfile_path, &emptyfile_name);
     3213   
     3214    m_pQueue->QueueFile(false, false, emptyfile_name, newFileName, localPath, m_pDirectoryListing->path, *pServer, 0);
     3215    m_pQueue->QueueFile_Finish(true);
     3216   
     3217    //m_pState->m_pCommandQueue->ProcessCommand(
     3218        //new CRenameCommand(m_pDirectoryListing->path, emptyfile_name, m_pDirectoryListing->path, newFileName) //Old name decided by fair dice roll. Guaranteed to be random.
     3219    //);
     3220}
  • src/interface/RemoteListView.h

    diff -rup filezilla/src/interface/RemoteListView.h filezilla-new/src/interface/RemoteListView.h
    old new protected:  
    115115    void OnMenuEnter(wxCommandEvent& event);
    116116    void OnMenuGeturl(wxCommandEvent& event);
    117117    void OnMenuRefresh(wxCommandEvent& event);
     118    void OnMenuNewfile(wxCommandEvent& event);
    118119};
    119120
    120121#endif
  • src/interface/resources/menus.xrc

    diff -rup filezilla/src/interface/resources/menus.xrc filezilla-new/src/interface/resources/menus.xrc
    old new  
    299299      <label>&amp;Create directory</label>
    300300      <help>Create a new subdirectory in the current directory</help>
    301301    </object>
     302    <object class="wxMenuItem" name="ID_NEW_FILE">
     303      <label>Cre&amp;ate new file</label>
     304      <help>Create a new, empty file in the current directory</help>
     305    </object>
    302306    <object class="wxMenuItem" name="ID_CONTEXT_REFRESH">
    303307      <label>Re&amp;fresh</label>
    304308    </object>