void DiffSideBySidePanel::DiffNew(const wxFileName& left, const wxFileName& right)
{
    if(!left.Exists()) {
        ::wxMessageBox(wxString() << _("Left Side File:\n") << left.GetFullPath() << _(" does not exist!"), "CodeLite",
            wxICON_ERROR | wxCENTER | wxOK);
        return;
    }

    if(!right.Exists()) {
        ::wxMessageBox(wxString() << _("Right Side File:\n") << right.GetFullPath() << _(" does not exist!"),
            "CodeLite", wxICON_ERROR | wxCENTER | wxOK);
        return;
    }

    m_staticTextLeft->Hide();
    m_staticTextRight->Hide();
    m_flags = kSavePaths; // store the paths on exit
    m_config.SetViewMode(DiffConfig::kViewVerticalSplit);
    m_splitter->Unsplit();
    m_splitter->SplitVertically(m_splitterPageLeft, m_splitterPageRight);

    // Restore last used paths
    m_config.Load();
    m_textCtrlLeftFile->ChangeValue(left.GetFullPath());
    m_textCtrlRightFile->ChangeValue(right.GetFullPath());

    CallAfter(&DiffSideBySidePanel::Diff); // trigger a diff
}
Example #2
0
void clSFTP::Write(const wxFileName& localFile, const wxString& remotePath) throw(clException)
{
    if(!m_connected) {
        throw clException("scp is not initialized!");
    }

    if(!localFile.Exists()) {
        throw clException(wxString() << "scp::Write file '" << localFile.GetFullPath() << "' does not exist!");
    }

    wxFFile fp(localFile.GetFullPath(), "rb");
    if(!fp.IsOpened()) {
        throw clException(wxString() << "scp::Write could not open file '" << localFile.GetFullPath() << "'. "
                                     << ::strerror(errno));
    }

    char buffer[4096];
    wxMemoryBuffer memBuffer;
    size_t nbytes(0);
    while(!fp.Eof()) {
        nbytes = fp.Read(buffer, sizeof(buffer));
        if(nbytes == 0) break;
        memBuffer.AppendData(buffer, nbytes);
    }
    fp.Close();
    Write(memBuffer, remotePath);
}
Example #3
0
bool CMakePlugin::ExistsCMakeLists(wxFileName directory) const
{
    // Add CMakeLists.txt
    directory.SetFullName(CMAKELISTS_FILE);

    return directory.Exists();
}
Example #4
0
void PluginManager::StoreWorkspaceSession(const wxFileName& workspaceFile)
{
    if(workspaceFile.Exists()) {
        SessionEntry session;
        clMainFrame::Get()->GetMainBook()->CreateSession(session);
        session.SetWorkspaceName(workspaceFile.GetFullPath());
        SessionManager::Get().Save(session.GetWorkspaceName(), session);
    }
}
bool NodeJSWorkspace::Create(const wxFileName& filename)
{
    if(IsOpen()) return false;
    if(filename.Exists()) return false;
    DoClear();
    m_filename = filename;

    // By default add the workspace path
    m_folders.Add(m_filename.GetPath());
    Save();

    // We dont load the workspace
    DoClear();
    return true;
}
Example #6
0
void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName )
{
    // The project file should be valid by the time we get here or something has gone wrong.
    if( !aProjectFileName.Exists() )
        return;

    // Any open KIFACE's must be closed if they are not part of the new project.
    // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.)
    // User is prompted here to close those KIWAY_PLAYERs:
    if( !Kiway().PlayersClose( false ) )
        return;

    SetTitle( wxString( "KiCad " ) + GetBuildVersion() );

    // Save the project file for the currently loaded project.
    if( m_active_project )
        Prj().ConfigLoad( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );

    m_active_project = true;
    ClearMsg();
    SetProjectFileName( aProjectFileName.GetFullPath() );
    Prj().ConfigLoad( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );

    wxString title = GetTitle() + " " + aProjectFileName.GetFullPath();

    if( !aProjectFileName.IsDirWritable() )
        title += _( " [Read Only]" );
    else
        SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why?

    SetTitle( title );

    UpdateFileHistory( aProjectFileName.GetFullPath(), &PgmTop().GetFileHistory() );

    m_LeftWin->ReCreateTreePrj();

    // Rebuild the list of watched paths.
    // however this is possible only when the main loop event handler is running,
    // so we use it to run the rebuild function.
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS );

    wxPostEvent( this, cmd );

    PrintPrjInfo();
}
wxFileName CompilationDatabase::ConvertCodeLiteCompilationDatabaseToCMake(const wxFileName& compile_file)
{
    wxFFile fp(compile_file.GetFullPath(), wxT("rb"));
    if( fp.IsOpened() ) {
        wxString content;
        fp.ReadAll(&content, wxConvUTF8);

        if( content.IsEmpty() )
            return wxFileName();
        
        JSONRoot root(cJSON_Array);
        JSONElement arr = root.toElement();
        wxArrayString lines = ::wxStringTokenize(content, "\n\r", wxTOKEN_STRTOK);
        for(size_t i=0; i<lines.GetCount(); ++i) {
            wxArrayString parts = ::wxStringTokenize(lines.Item(i), wxT("|"), wxTOKEN_STRTOK);
            if( parts.GetCount() != 3 )
                continue;

            wxString file_name = wxFileName(parts.Item(0).Trim().Trim(false)).GetFullPath();
            wxString cwd       = parts.Item(1).Trim().Trim(false);
            wxString cmp_flags = parts.Item(2).Trim().Trim(false);

            JSONElement element = JSONElement::createObject();
            element.addProperty("directory", cwd);
            element.addProperty("command",   cmp_flags);
            element.addProperty("file",      file_name);
            arr.arrayAppend( element );
        }
        
        wxFileName fn(compile_file.GetPath(), "compile_commands.json");
        root.save( fn );
        // Delete the old file
        {
            wxLogNull nl;
            fp.Close();
            if ( compile_file.Exists() ) {
                ::wxRemoveFile( compile_file.GetFullPath() );
            }
        }
        return fn;
    }
    return wxFileName();
}
Example #8
0
void clSFTP::Write(const wxFileName& localFile, const wxString& remotePath) throw (clException)
{
    if ( !m_connected ) {
        throw clException("scp is not initialized!");
    }

    if ( !localFile.Exists() ) {
        throw clException(wxString() << "scp::Write file '" << localFile.GetFullPath() << "' does not exist!");
    }

    wxFFile fp(localFile.GetFullPath(), "rb");
    if ( !fp.IsOpened() ) {
        throw clException(wxString() << "scp::Write could not open file '" << localFile.GetFullPath() << "'. " << ::strerror(errno) );
    }

    wxString fileContent;
    fp.ReadAll(&fileContent);

    Write(fileContent, remotePath);
}
Example #9
0
void PluginManager::AddWorkspaceToRecentlyUsedList(const wxFileName& filename)
{
    if(filename.Exists()) {
        ManagerST::Get()->AddToRecentlyOpenedWorkspaces(filename.GetFullPath());
    }
}