⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configtool.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.// Copyright (C) 2003 John Dallaway//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it// under the terms of the GNU General Public License as published by the Free// Software Foundation; either version 2 of the License, or (at your option)// any later version.//// This program is distributed in the hope that it will be useful, but WITHOUT// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for// more details.//// You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.//// ----------------------------------------------------------------------------////####COPYRIGHTEND####// configtool.cpp :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):   julians, jld// Contact(s):  julians, jld// Date:        2000/08/24// Version:     $Id: configtool.cpp,v 1.51 2001/12/11 15:59:51 julians Exp $// Purpose:// Description: Implementation file for the ConfigTool application class// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__    #pragma implementation "configtool.h"#endif// Includes other headers for precompiled compilation#include "ecpch.h"#ifdef __BORLANDC__    #pragma hdrstop#endif#include "eCosSocket.h"#include "eCosTestPlatform.h"#include "wx/splash.h"#include "wx/cshelp.h"#include "wx/image.h"#include "wx/filesys.h"#include "wx/fs_zip.h"#include "wx/config.h"#include "wx/cmdline.h"#include "wx/process.h"#include "wx/mimetype.h"#include "wx/txtstrm.h"#include "wx/wfstream.h"#include "wx/fs_mem.h"#include "configtool.h"#include "configtoolview.h"#include "configtree.h"#include "mainwin.h"#include "outputwin.h"#include "configtooldoc.h"#include "aboutdlg.h"#include "shortdescrwin.h"#include "conflictwin.h"#include "propertywin.h"#include "symbols.h"#include "build.hxx"#include "Subprocess.h"// ----------------------------------------------------------------------------// resources// ----------------------------------------------------------------------------// the application icon#if defined(__WXGTK__) || defined(__WXMOTIF__)    #include "bitmaps/configtool.xpm"#endif// Create a new application object.IMPLEMENT_APP(ecApp)BEGIN_EVENT_TABLE(ecApp, wxApp)// Don't handle automatically, or it will bypass more specific processing.//    EVT_MENU(ecID_WHATS_THIS, ecApp::OnWhatsThis)END_EVENT_TABLE()bool ecApp::sm_arMounted[26]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};static const wxCmdLineEntryDesc sg_cmdLineDesc[] ={/*    { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" },    { wxCMD_LINE_SWITCH, "q", "quiet",   "be quiet" },    { wxCMD_LINE_OPTION, "o", "output",  "output file" },    { wxCMD_LINE_OPTION, "i", "input",   "input dir" },    { wxCMD_LINE_OPTION, "s", "size",    "output block size", wxCMD_LINE_VAL_NUMBER },    { wxCMD_LINE_OPTION, "d", "date",    "output file date", wxCMD_LINE_VAL_DATE },*/    { wxCMD_LINE_SWITCH, "h", "help",   "displays help on the command line parameters" },    { wxCMD_LINE_SWITCH, "e", "edit-only",    "edit save file only" },    { wxCMD_LINE_SWITCH, "v", "version",    "print version" },    { wxCMD_LINE_SWITCH, "c", "compile-help",    "compile online help only" },    { wxCMD_LINE_PARAM,  NULL, NULL, "input file 1", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },    { wxCMD_LINE_PARAM,  NULL, NULL, "input file 2", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },    { wxCMD_LINE_NONE }};ecApp::ecApp(){    m_docManager = NULL;    m_mainFrame = NULL;    m_currentDoc = NULL;    m_whatsThisMenu = new wxMenu;    m_whatsThisMenu->Append(ecID_WHATS_THIS, _("&What's This?"));    m_helpFile = wxEmptyString;    m_splashScreen = NULL;    m_pipedProcess = NULL;    m_valuesLocked = 0;    m_helpController = NULL;    m_fileSystem = new wxFileSystem;#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB    m_zipHandler = new wxZipFSHandler;#endif}ecApp::~ecApp(){    delete m_whatsThisMenu;    delete m_fileSystem;}// 'Main program' equivalent: the program execution "starts" herebool ecApp::OnInit(){    wxLog::SetTimestamp(NULL);    wxHelpProvider::Set(new wxSimpleHelpProvider);    //wxHelpProvider::Set(new wxHelpControllerHelpProvider(& m_helpController));    wxImage::AddHandler(new wxPNGHandler);    wxImage::AddHandler(new wxGIFHandler);    // Required for advanced HTML help#if wxUSE_STREAMS && wxUSE_ZIPSTREAM && wxUSE_ZLIB    wxFileSystem::AddHandler(m_zipHandler);#endif    // Mandatory initialisation for Tcl 8.4    Tcl_FindExecutable(argv[0]);    wxString currentDir = wxGetCwd();    // Use argv to get current app directory    m_appDir = wxFindAppPath(argv[0], currentDir, wxT("CONFIGTOOLDIR"));        // If the development version, go up a directory.#ifdef __WXMSW__    if ((m_appDir.Right(5).CmpNoCase("DEBUG") == 0) ||        (m_appDir.Right(11).CmpNoCase("DEBUGSTABLE") == 0) ||        (m_appDir.Right(7).CmpNoCase("RELEASE") == 0) ||        (m_appDir.Right(13).CmpNoCase("RELEASESTABLE") == 0)        )        m_appDir = wxPathOnly(m_appDir);#endif// Install default platform definitions if no platforms defined#ifdef __WXMSW__    wxConfig config (wxGetApp().GetSettings().GetConfigAppName());    if (! config.Exists (wxT("Platforms")))    {        wxFileName platforms (m_appDir, wxT("platforms.reg"));        platforms.Normalize();        if (platforms.FileExists())            wxExecute (wxT("regedit /s \"") + platforms.GetFullPath() + wxT("\""), wxEXEC_SYNC);    }#endif#ifdef __WXGTK__    wxFileName config (wxFileName::GetHomeDir(), wxEmptyString);    config.AppendDir(wxT(".eCosPlatforms"));    if (! config.DirExists())    {        wxFileName platforms (m_appDir, wxT("platforms.tar"));        platforms.Normalize();        if (platforms.FileExists())            wxExecute (wxT("tar -C ") + wxFileName::GetHomeDir() + wxT(" -xf ") + platforms.GetFullPath(), wxEXEC_SYNC);    }#endif    CeCosSocket::Init();    CeCosTestPlatform::Load();    // Load resources from binary resources archive, or failing that, from    // Windows resources or plain files    LoadResources();    wxGetEnv(wxT("PATH"), & m_strOriginalPath);    // Create a document manager    m_docManager = new wxDocManager;    // Create a template relating documents to their views    wxDocTemplate* templ = new wxDocTemplate(m_docManager, "Configtool", "*.ecc", "", "ecc", "Configtool Doc", "Configtool View",        CLASSINFO(ecConfigToolDoc), CLASSINFO(ecConfigToolView));    // If we've only got one window, we only get to edit    // one document at a time.    m_docManager->SetMaxDocsOpen(1);        // Initialize config settings    m_settings.Init();    // Let wxWindows know what the app name is    SetAppName(m_settings.GetAppName());    InitializeWindowSettings(TRUE /* beforeWindowConstruction */) ;    // Load config settings    m_settings.LoadConfig();    // Set the default directory for opening/saving files    if (!m_settings.m_lastFilename.IsEmpty())        templ->SetDirectory(wxPathOnly(m_settings.m_lastFilename));    // Parse the command-line parameters and options    wxCmdLineParser parser(sg_cmdLineDesc, argc, argv);    int res;    {        wxLogNull log;        res = parser.Parse();    }    if (res == -1 || res > 0 || parser.Found(wxT("h")))    {#ifdef __WXGTK__        wxLog::SetActiveTarget(new wxLogStderr);#endif        parser.Usage();        return FALSE;    }    if (parser.Found(wxT("v")))    {#ifdef __WXGTK__        wxLog::SetActiveTarget(new wxLogStderr);#endif        wxString msg;        msg.Printf(wxT("eCos Configuration Tool (c) Red Hat, 2001 Version %s, %s"), ecCONFIGURATION_TOOL_VERSION, __DATE__);        wxLogMessage(msg);        return FALSE;    }/*#ifdef __WXMSW__    wxBitmap bitmap(wxBITMAP(splash));#else    wxBitmap bitmap;    if (wxFileExists("splash16.png"))        bitmap.LoadFile("splash16.png", wxBITMAP_TYPE_PNG);#endif*/    //    wxYieldIfNeeded();    // create the main application window    ecMainFrame *frame = new ecMainFrame(m_docManager, GetSettings().GetAppName(),        wxPoint(GetSettings().m_frameSize.x, GetSettings().m_frameSize.y),        wxSize(GetSettings().m_frameSize.width, GetSettings().m_frameSize.height));    m_mainFrame = frame;    SetTopWindow(frame);    frame->Show(TRUE);    SendIdleEvents(); // Otherwise UI updates aren't done, because it's busy loading the repository#ifdef __WXMSW__    ::UpdateWindow((HWND) frame->GetHWND());#endif    InitializeWindowSettings(FALSE /* beforeWindowConstruction */) ;    if (m_splashScreenBitmap.Ok() && GetSettings().m_showSplashScreen)    {        m_splashScreen = new ecSplashScreen(m_splashScreenBitmap, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,            5000, NULL, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP);    }    //    if (m_splashScreen)    //        m_splashScreen->Raise();    wxYieldIfNeeded();    if (parser.Found(wxT("e")))        GetSettings().m_editSaveFileOnly = TRUE;    // If in --compile-help (-c) mode, then exit immediately after recompiling help file    bool compileHelpOnly = parser.Found(wxT("c"));    wxString filenameToOpen1, filenameToOpen2;    if (parser.GetParamCount() > 0)    {        wxString tmpSaveFile;        filenameToOpen1 = parser.GetParam(0);        if (parser.GetParamCount() > 1)            filenameToOpen2 = parser.GetParam(1);        bool gotRepository = FALSE;        bool gotSavefile = FALSE;        wxString repositoryDir, saveFile;        // Might be e.g. . or .. in path, or relative path        filenameToOpen1 = wxGetRealPath(currentDir, filenameToOpen1);        if (parser.GetParamCount() > 1)            filenameToOpen2 = wxGetRealPath(currentDir, filenameToOpen2);        wxString path1, name1, ext1;        wxSplitPath(filenameToOpen1, & path1, & name1, & ext1);        wxString path2, name2, ext2;        wxSplitPath(filenameToOpen2, & path2, & name2, & ext2);        // Look at the first file        if (ext1 == "ecc" || ext1 == "ECC")        {            if (wxFileExists(filenameToOpen1))            {                gotSavefile = TRUE;                saveFile = filenameToOpen1;            }            else            {                wxString msg;                msg.Printf("%s is not a valid file.", (const wxChar*) filenameToOpen1);                wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK);                return FALSE;            }        }        else if (wxDirExists(filenameToOpen1) && FindSaveFileInDir(filenameToOpen1, tmpSaveFile))        {            saveFile = tmpSaveFile;            gotSavefile = TRUE;        }        else if ((name1 == wxT("ecos") && ext1 == wxT("db") && wxFileExists(filenameToOpen1)) || wxDirExists(filenameToOpen1))        {            // It's a repository (we hope).            if (name1 == wxT("ecos") && ext1 == wxT("db"))            {                // Go two steps up                filenameToOpen1 = wxPathOnly(filenameToOpen1);                filenameToOpen1 = wxPathOnly(filenameToOpen1);            }            else            {                // If it's the packages directory, we need to strip off                // a directory                wxString eccPath(filenameToOpen1 + wxString(wxFILE_SEP_PATH) + wxT("ecc"));                // Don't strip off ecc if it's the CVS repository (with ecc below it)                if (name1 == wxT("packages") || (name1 == wxT("ecc") && !wxDirExists(eccPath)))                    filenameToOpen1 = wxPathOnly(filenameToOpen1);            }            repositoryDir = filenameToOpen1;            gotRepository = TRUE;        }        else        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -