void DIALOG_TEMPLATE_SELECTOR::AddPage( const wxString& aTitle, wxFileName& aPath )
{
    wxNotebookPage* newPage = new wxNotebookPage( m_notebook, wxID_ANY );
    m_notebook->AddPage( newPage, aTitle );

    TEMPLATE_SELECTION_PANEL* p = new TEMPLATE_SELECTION_PANEL( newPage );
    m_panels.push_back( p );

    // Get a list of files under the template path to include as choices...
    wxArrayString files;
    wxDir dir, sub;

    if ( dir.Open( aPath.GetPath() ) )
    {
        wxString filename;
        bool cont = dir.GetFirst( &filename, wxEmptyString, wxDIR_FILES | wxDIR_DIRS );

        while( cont )
        {
            if( sub.Open( aPath.GetPathWithSep() + filename ) )
            {
                files.Add( filename );
                PROJECT_TEMPLATE* pt = new PROJECT_TEMPLATE( aPath.GetPathWithSep() + filename );
                AddTemplate( m_notebook->GetPageCount() - 1, pt );
            }

            cont = dir.GetNext( &filename );
        }
    }
}
예제 #2
0
/*! \brief Get the global configuration directory path.
 *
 * \return wxString    The directory path with trailing separator.
 *
 */
wxString DoxyBlocksConfig::GetCBConfigDir()
{
    PersonalityManager* PersMan = Manager::Get()->GetPersonalityManager();
    const wxString personality = PersMan->GetPersonality();
    ConfigManager* CfgMan = Manager::Get()->GetConfigManager(_T("app"));
    const wxFileName fnConf(CfgMan->LocateDataFile(personality+_T(".conf"), sdAllKnown));
    return fnConf.GetPathWithSep();
}
예제 #3
0
bool wxFileSystemWatcherBase::AddTree(const wxFileName& path, int events,
                                      const wxString& filespec)
{
    if (!path.DirExists())
        return false;

    // OPT could be optimised if we stored information about relationships
    // between paths
    class AddTraverser : public wxDirTraverser
    {
    public:
        AddTraverser(wxFileSystemWatcherBase* watcher, int events,
                     const wxString& filespec) :
            m_watcher(watcher), m_events(events), m_filespec(filespec)
        {
        }

        virtual wxDirTraverseResult OnFile(const wxString& WXUNUSED(filename))
        {
            // There is no need to watch individual files as we watch the
            // parent directory which will notify us about any changes in them.
            return wxDIR_CONTINUE;
        }

        virtual wxDirTraverseResult OnDir(const wxString& dirname)
        {
            if ( m_watcher->AddAny(wxFileName::DirName(dirname),
                                   m_events, wxFSWPath_Tree, m_filespec) )
            {
                wxLogTrace(wxTRACE_FSWATCHER,
                   "--- AddTree adding directory '%s' ---", dirname);
            }
            return wxDIR_CONTINUE;
        }

    private:
        wxFileSystemWatcherBase* m_watcher;
        int m_events;
        wxString m_filespec;
    };

    wxDir dir(path.GetFullPath());
    // Prevent asserts or infinite loops in trees containing symlinks
    int flags = wxDIR_DIRS;
    if ( !path.ShouldFollowLink() )
    {
        flags |= wxDIR_NO_FOLLOW;
    }
    AddTraverser traverser(this, events, filespec);
    dir.Traverse(traverser, filespec, flags);

    // Add the path itself explicitly as Traverse() doesn't return it.
    AddAny(path.GetPathWithSep(), events, wxFSWPath_Tree, filespec);

    return true;
}
bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath )
{
    bool result = true;

    vector<wxFileName> srcFiles = GetFileList();
    vector<wxFileName> dstFiles;

    for( size_t i=0; i < srcFiles.size(); i++ )
    {
        // Replace the template path
        wxFileName destination = srcFiles[i];
        wxString destname = destination.GetName();

        // Replace the template name with the project name for the new project creation
        destname.Replace( GetName(), aNewProjectPath.GetName() );

        // Add the file extension (if there was one!)
        if( destination.GetExt() != wxEmptyString )
            destname += wxT(".") + destination.GetExt();

        wxString destpath = destination.GetPathWithSep();
        destpath.Replace( templateBasePath.GetPathWithSep(), aNewProjectPath.GetPathWithSep() );

        // Check to see if the path already exists, if not attempt to create it here. Don't worry
        // about error checking, if the path isn't created the file copy will fail anyway

        if( !wxFileName::DirExists( destpath ) )
            wxFileName::Mkdir( destpath, 0777, wxPATH_MKDIR_FULL );

        destination = destpath + destname;
        dstFiles.push_back( destination );

        wxString srcFile = srcFiles[i].GetFullPath();
        wxString dstFile = dstFiles[i].GetFullPath();

        if( !wxCopyFile( srcFile, dstFile ) )
        {
            result = false;
            break;
        }
    }

    return result;
}
예제 #5
0
void t4p::SetSettingsDirLocation(const wxFileName& settingsDir) {
    wxFileName bootstrapConfigFile;
    wxStandardPaths paths = wxStandardPaths::Get();
    wxFileName executableDir(paths.GetExecutablePath());

    // the settings dir is in the same directory as the executable. save
    // settings dir in the local bootstrap file
    if (settingsDir.GetPathWithSep().Find(executableDir.GetPathWithSep()) != wxNOT_FOUND) {
        bootstrapConfigFile.Assign(paths.GetExecutablePath());
        bootstrapConfigFile.SetFullName(wxT(".triumph4php-bootstrap.ini"));
    } else {
        // save settings dire in the global bootstrap config file
        bootstrapConfigFile.AssignDir(paths.GetUserConfigDir());
        bootstrapConfigFile.SetFullName(wxT(".triumph4php-bootstrap.ini"));
    }
    wxString bootstrapFullPath = bootstrapConfigFile.GetFullPath();
    wxFileConfig bootstrapConfig(wxT("bootstrap"), wxEmptyString,
                                 bootstrapFullPath, wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
    wxString s = settingsDir.GetPath();
    bootstrapConfig.Write(wxT("SettingsDirectory"), s);
    bootstrapConfig.Flush();
}