void CscopePlugin::DoCscopeCommand(const wxString &cmd, const wxString &endMsg) { ClearOutputWindow(); MakeOutputPaneVisible(); m_CscouptOutput.clear(); cbProject * prj = Manager::Get()->GetProjectManager()->GetActiveProject(); wxString path; if ( prj ) path = prj->GetBasePath(); Manager::Get()->GetLogManager()->Log(cmd); m_EndMsg = endMsg; if ( m_pProcess ) return; wxString curDir = wxGetCwd(); wxSetWorkingDirectory(path); //set environment variables for cscope wxSetEnv(_T("TMPDIR"), _T(".")); m_view->GetWindow()->SetMessage(_T("Executing cscope..."), 10); m_pProcess = new CscopeProcess(this); if ( !wxExecute(cmd, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER, m_pProcess) ) { delete m_pProcess; m_pProcess = NULL; m_view->GetWindow()->SetMessage(_T("Error while calling cscope occurred!"), 0); } //set environment variables back Manager::Get()->GetLogManager()->Log(_T("cscope process started")); wxSetWorkingDirectory(curDir); }
bool Spring::LaunchSpring( const wxString& params ) { if ( m_running ) { wxLogError( _T("Spring already running!") ); return false; } if ( !wxFile::Exists( sett().GetCurrentUsedSpringBinary() ) ) { customMessageBoxNoModal( SL_MAIN_ICON, _T("The spring executable was not found at the set location, please re-check."), _T("Executable not found") ); ui().mw().ShowConfigure( MainWindow::OPT_PAGE_SPRING ); return false; } wxString configfileflags = sett().GetCurrentUsedSpringConfigFilePath(); if ( !configfileflags.IsEmpty() ) { configfileflags = _T("--config=\"") + configfileflags + _T("\" "); #ifdef __WXMSW__ if ( usync().GetSpringVersion().Find(_T("0.78.") ) != wxNOT_FOUND ) configfileflags = _T(""); #endif } wxString cmd = _T("\"") + sett().GetCurrentUsedSpringBinary(); #ifdef __WXMAC__ wxChar sep = wxFileName::GetPathSeparator(); if ( sett().GetCurrentUsedSpringBinary().AfterLast(_T('.')) == _T("app") ) cmd += sep + wxString(_T("Contents")) + sep + wxString(_T("MacOS")) + sep + wxString(_T("spring")); // append app bundle inner path #endif cmd += _T("\" ") + configfileflags + params; wxLogMessage( _T("spring call params: %s"), cmd.c_str() ); wxSetWorkingDirectory( sett().GetCurrentUsedDataDir() ); if ( sett().UseOldSpringLaunchMethod() ) { if ( m_wx_process == 0 ) m_wx_process = new wxSpringProcess( *this ); if ( wxExecute( cmd , wxEXEC_ASYNC, m_wx_process ) == 0 ) return false; } else { if ( m_process == 0 ) m_process = new SpringProcess( *this ); m_process->Create(); m_process->SetCommand( cmd ); m_process->Run(); } m_running = true; return true; }
void CppLayoutPreviewer::PlayPreview() { playing = true; if ( wxDirExists(wxFileName::FileName(editor.GetProject().GetProjectFile()).GetPath())) wxSetWorkingDirectory(wxFileName::FileName(editor.GetProject().GetProjectFile()).GetPath()); std::cout << previewScene.GetProfiler() << "<-" << std::endl; if ( externalPreviewWindow ) externalPreviewWindow->Show(false); previewScene.ChangeRenderWindow(&editor); if ( debugger ) debugger->Play(); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPlay, false); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPause, true); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPlayWin, true); }
bool UpdateAction::Perform() { svn::Revision revision(svn::Revision::HEAD); // Did the user request a specific revision?: if (!m_data.useLatest) { TrimString(m_data.revision); if (!m_data.revision.IsEmpty()) { svn_revnum_t revnum; m_data.revision.ToLong(&revnum, 10); // If this fails, revnum is unchanged. revision = svn::Revision(revnum); } } const wxString & dir = Utf8ToLocal(GetPath().c_str()); if (!dir.empty()) wxSetWorkingDirectory(dir); svn::Client client(GetContext()); svn_depth_t depth = svn_depth_unknown; switch (m_data.depth) { default: case UPDATE_WORKING_COPY: depth = svn_depth_unknown; break; case UPDATE_FULLY_RECURSIVE: depth = svn_depth_infinity; break; case UPDATE_IMMEDIATES: depth = svn_depth_immediates; break; case UPDATE_FILES: depth = svn_depth_files; break; case UPDATE_EMPTY: depth = svn_depth_empty; break; } client.update(GetTargets(), revision, depth, m_data.stickyDepth, m_data.ignoreExternals); return true; }
bool LadspaEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxString & path) { // Since we now have builtin VST support, ignore the VST bridge as it // causes duplicate menu entries to appear. wxFileName f(path); if (f.GetName().CmpNoCase(wxT("vst-bridge")) == 0) { return false; } // As a courtesy to some plug-ins that might be bridges to // open other plug-ins, we set the current working // directory to be the plug-in's directory. wxString envpath; bool hadpath = wxGetEnv(wxT("PATH"), &envpath); wxSetEnv(wxT("PATH"), f.GetPath() + wxFILE_SEP_PATH + envpath); wxString saveOldCWD = f.GetCwd(); f.SetCwd(); int index = 0; LADSPA_Descriptor_Function mainFn = NULL; wxDynamicLibrary lib; if (lib.Load(path, wxDL_NOW)) { wxLogNull logNo; mainFn = (LADSPA_Descriptor_Function) lib.GetSymbol(wxT("ladspa_descriptor")); if (mainFn) { const LADSPA_Descriptor *data; for (data = mainFn(index); data; data = mainFn(++index)) { LadspaEffect effect(path, index); if (effect.SetHost(NULL)) { pm.RegisterPlugin(this, &effect); } } } } if (lib.IsLoaded()) { lib.Unload(); } wxSetWorkingDirectory(saveOldCWD); hadpath ? wxSetEnv(wxT("PATH"), envpath) : wxUnsetEnv(wxT("PATH")); return index > 0; }
//Format and (optionally) execute command bool ExecInput::FormatCommand(const GameType *gtype, const wxString &host, int port, const wxString &password, const wxString &name, wxString *out, bool execute) { wxString path, order, conn, pass, nm; wxString command; ReadExecOpts(gtype, &path, &order, &conn, &pass, &nm); if (path.IsEmpty() || order.IsEmpty() || conn.IsEmpty()) return false; VarMap vmap, optmap; vmap["host"] = host; vmap["port"] = wxString::Format("%d", port); optmap["connect_opt"] = VarSubst(conn, vmap); if (!password.IsEmpty() && !pass.IsEmpty()) { vmap["password"] = password; optmap["password_opt"] = VarSubst(pass, vmap); } if (!name.IsEmpty() && !nm.IsEmpty()) { vmap["name"] = name; optmap["name_opt"] = VarSubst(nm, vmap); } wxFileName exec(path); exec.Normalize(); wxSetWorkingDirectory(exec.GetPath()); command = exec.GetFullPath() + _T(" ") + VarSubst(order, optmap); if (out) *out = command; if (execute) wxExecute(command); return true; }
/* * Read a EXCELLON file. * Gerber classes are used because there is likeness between Gerber files * and Excellon files * DCode can easily store T code (tool size) as round (or oval) shape * Drill commands are similar to flashed gerber items * Routing commands are similar to Gerber polygons * coordinates have the same format as Gerber, can be given in: * decimal format (i.i. floating notation format) * integer 2.4 format in imperial units, * integer 3.2 or 3.3 format (metric units). */ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; int layerId = getActiveLayer(); // current layer used in GerbView EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List.GetGbrImage( layerId ); if( drill_Layer == NULL ) { drill_Layer = new EXCELLON_IMAGE( this, layerId ); layerId = g_GERBER_List.AddGbrImage( drill_Layer, layerId ); } if( layerId < 0 ) { DisplayError( this, _( "No room to load file" ) ); return false; } ClearMessageList(); // Read the Excellon drill file: FILE * file = wxFopen( aFullFileName, wxT( "rt" ) ); if( file == NULL ) { msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) ); DisplayError( this, msg ); return false; } wxString path = wxPathOnly( aFullFileName ); if( path != wxEmptyString ) wxSetWorkingDirectory( path ); bool success = drill_Layer->Read_EXCELLON_File( file, aFullFileName ); // Display errors list if( m_Messages.size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) ); dlg.ListSet( m_Messages ); dlg.ShowModal(); } return success; }
bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific #if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON InstallDebugAssertOutputHandler( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) ); #endif // Mac OS X passes a process serial number command line argument when // the application is launched from the Finder. This argument must be // removed from the command line arguments before being handled by the // application (otherwise applications would need to handle it) if ( argc > 1 ) { static const wxChar *ARG_PSN = wxT("-psn_"); if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) { // remove this argument --argc; memmove(argv + 1, argv + 2, argc * sizeof(char *)); } } if ( !wxAppBase::Initialize(argc, argv) ) return false; #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif // these might be the startup dirs, set them to the 'usual' dir containing the app bundle wxString startupCwd = wxGetCwd() ; if ( startupCwd == wxT("/") || startupCwd.Right(15) == wxT("/Contents/MacOS") ) { CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle() ) ; CFURLRef urlParent = CFURLCreateCopyDeletingLastPathComponent( kCFAllocatorDefault , url ) ; CFRelease( url ) ; CFStringRef path = CFURLCopyFileSystemPath ( urlParent , kCFURLPOSIXPathStyle ) ; CFRelease( urlParent ) ; wxString cwd = wxCFStringRef(path).AsString(wxLocale::GetSystemEncoding()); wxSetWorkingDirectory( cwd ) ; } return true; }
void EnviroFrame::Snapshot(bool bNumbered) { VTLOG1("EnviroFrame::Snapshot\n"); wxString use_name; if (!bNumbered || (bNumbered && m_strSnapshotFilename == _T(""))) { // save current directory wxString path = wxGetCwd(); wxString filter = FSTRING_JPEG _T("|") FSTRING_BMP _T("|") FSTRING_PNG _T("|") FSTRING_TIF; EnableContinuousRendering(false); wxFileDialog saveFile(NULL, _("Save View Snapshot"), _T(""), _T(""), filter, wxFD_SAVE); bool bResult = (saveFile.ShowModal() == wxID_OK); EnableContinuousRendering(true); if (!bResult) { wxSetWorkingDirectory(path); // restore return; } if (bNumbered) { m_strSnapshotFilename = saveFile.GetPath(); m_iSnapshotNumber = 0; } else use_name = saveFile.GetPath(); } if (bNumbered) { // Append the number of the snapshot to the filename wxString start, number, extension; start = m_strSnapshotFilename.BeforeLast(_T('.')); extension = m_strSnapshotFilename.AfterLast(_T('.')); number.Printf(_T("_%03d."), m_iSnapshotNumber); m_iSnapshotNumber++; use_name = start + number + extension; } std::string Filename(use_name.mb_str(wxConvUTF8)); CScreenCaptureHandler::SetupScreenCapture(Filename); }
bool EnviroGUI::SaveStructures(bool bAskFilename) { VTLOG1("EnviroGUI::SaveStructures\n"); vtStructureLayer *st_layer = GetCurrentTerrain()->GetStructureLayer(); vtString fname = st_layer->GetFilename(); if (bAskFilename) { // save current directory wxString path = wxGetCwd(); wxString default_file(StartOfFilename(fname), wxConvUTF8); wxString default_dir(ExtractPath(fname, false), wxConvUTF8); EnableContinuousRendering(false); wxFileDialog saveFile(NULL, _("Save Built Structures Data"), default_dir, default_file, FSTRING_VTST, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); bool bResult = (saveFile.ShowModal() == wxID_OK); EnableContinuousRendering(true); if (!bResult) { wxSetWorkingDirectory(path); // restore return false; } wxString str = saveFile.GetPath(); fname = str.mb_str(wxConvUTF8); st_layer->SetFilename(fname); } bool success = false; try { success = st_layer->WriteXML(fname); } catch (xh_io_exception &e) { string str = e.getFormattedMessage(); VTLOG(" Error: %s\n", str.c_str()); wxMessageBox(wxString(str.c_str(), wxConvUTF8), _("Error")); } if (success) st_layer->SetModified(false); return success; }
bool ALMRunConfig::set(const wxString& name,const wxString &value) { if (name.Cmp("Explorer") == 0) Explorer = value; else if (name.Cmp("Root") == 0) { Root = value; if (Root.empty()) return false; wxSetWorkingDirectory(Root); } else if(name.Cmp("HotKey") == 0) HotKey = value; else if(name.Cmp("HotKeyReLoad") == 0) HotKeyReLoad = value; else return false; return ::wxSetEnv(wxT("ALMRUN_")+name.Upper(),value); }
void WinEDA_MainFrame::Load_Prj_Config(void) /*******************************************/ { if ( ! wxFileExists(m_PrjFileName) ) { wxString msg = _("Project File <") + m_PrjFileName + _("> not found"); DisplayError(this, msg); return; } wxSetWorkingDirectory(wxPathOnly(m_PrjFileName) ); SetTitle(g_Main_Title + wxT(" ") + GetBuildVersion() + wxT(" ") + m_PrjFileName); ReCreateMenuBar(); m_LeftWin->ReCreateTreePrj(); wxString msg = _("\nWorking dir: ") + wxGetCwd(); msg << _("\nProject: ") << m_PrjFileName << wxT("\n"); PrintMsg(msg); }
bool MergeAction::Perform() { svn::Client client(GetContext()); // Set current working directory to the path where the // merge will be performed. If Destination is a file and not a // directory, only the directory part should be used wxFileName path(m_data.Destination); if (!wxSetWorkingDirectory(path.GetPath(wxPATH_GET_VOLUME))) { wxString msg; msg.Printf(_("Could not set working directory to %s"), path.GetPath(wxPATH_GET_VOLUME).c_str()); TraceError(msg); return false; } svn_revnum_t rev1 = 0; svn_revnum_t rev2 = 0; if (!m_data.Path1Rev.ToLong(&rev1) || !m_data.Path2Rev.ToLong(&rev2)) { wxString msg = _("Invalid revision number detected"); TraceError(msg); return false; } svn::Path path1Utf8(PathUtf8(m_data.Path1)); svn::Path path2Utf8(PathUtf8(m_data.Path2)); svn::Path destinationUtf8(PathUtf8(m_data.Destination)); client.merge(path1Utf8, rev1, path2Utf8, rev2, destinationUtf8, m_data.Force, m_data.Recursive); return true; }
bool EnviroGUI::SaveVegetation(bool bAskFilename) { VTLOG1("EnviroGUI::SaveVegetation\n"); vtTerrain *pTerr = GetCurrentTerrain(); vtVegLayer *vlay = pTerr->GetVegLayer(); if (!vlay) return false; vtString fname = vlay->GetFilename(); if (bAskFilename) { // save current directory wxString path = wxGetCwd(); wxString default_file(StartOfFilename(fname), wxConvUTF8); wxString default_dir(ExtractPath(fname, false), wxConvUTF8); EnableContinuousRendering(false); wxFileDialog saveFile(NULL, _("Save Vegetation Data"), default_dir, default_file, FSTRING_VF, wxFD_SAVE); bool bResult = (saveFile.ShowModal() == wxID_OK); EnableContinuousRendering(true); if (!bResult) { wxSetWorkingDirectory(path); // restore return false; } wxString str = saveFile.GetPath(); fname = str.mb_str(wxConvUTF8); vlay->SetFilename(fname); } bool success = vlay->WriteVF(fname); if (success) vlay->SetModified(false); return true; }
void CShowOneDescriptionDlg::OnButton(wxCommandEvent& event) { if (event.GetId()==wxID_OK) { int err; wxString CurrentDir = wxGetCwd(); if (!m_descr) return; wxFileDialog dialog(GetParent(), wxT("Save current text"), wxT(""), wxT(""), wxT(SZ_ALL_FILES), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); err = dialog.ShowModal(); wxSetWorkingDirectory(CurrentDir); if (wxID_OK == err) { CFileWriter F; if (F.Open(dialog.GetPath().mb_str())) { F.WriteBuf(m_descr, strlen(m_descr)); F.Close(); } else wxMessageBox(wxT("Can not open file")); } } else if (event.GetId()==wxID_CANCEL) { StoreSize(); EndModal(wxID_CANCEL); } }
void dlg_options::OnStartLogging(wxCommandEvent &event) { if (m_frame->m_child->IsLogging()) { m_frame->m_child->SetLogging(false); m_startlog->SetLabel(_("Start logging")); } else { m_frame->m_child->SetLogging(true); m_startlog->SetLabel(_("Stop logging")); m_frame->m_child->SetHtmlLogging(m_logopts->GetSelection()==0); m_frame->m_child->SetAnsiLogging(m_logopts->GetSelection()==2); m_frame->m_child->SetDateLogging(m_ts->GetValue()); m_frame->m_child->SetInclude(m_includescroll->GetValue()); wxString path = m_dirPicker1->GetPath(); wxString file = m_logfile->GetValue(); wxSetWorkingDirectory(path); wxFile *f = new wxFile(file, wxFile::write); if (m_frame->m_child->IsHtmlLogging()) { m_frame->m_child->SetHtmlLog(f); m_frame->m_child->WriteHtmlHeader(f); } else { m_frame->m_child->SetTextLog(f); } if (m_frame->m_child->GetInclude()) { for (int i =0;i<m_frame->m_child->m_curline-1;i++) { m_frame->m_child->SendLineToLog(i); } } } }
void WinEDA_MainFrame::Load_Prj_Config(void) /*******************************************/ { FILE * in_file; in_file = fopen(m_PrjFileName, "rt"); if ( in_file == 0 ) { wxString msg = _("Project File <") + m_PrjFileName + _("> not found"); DisplayError(this, msg); return; } fclose(in_file); wxSetWorkingDirectory(wxPathOnly(m_PrjFileName) ); SetTitle(Main_Title + " " + m_PrjFileName); ReCreateMenuBar(); m_LeftWin->ReCreateTreePrj(); wxString msg = _("\nWorking dir: ") + wxGetCwd(); msg << _("\nProject: ") << m_PrjFileName << "\n"; PrintMsg(msg); }
bool Spring::LaunchEngine(const std::string& cmd, wxArrayString& params) { if ( m_running ) { wxLogError( _T("Spring already running!") ); return false; } if (cfg().ReadBool(_T( "/Spring/Safemode" ))) { params.push_back(_T("--safemode")); } wxLogMessage( _T("spring call params: %s"), TowxString(cmd).c_str() ); wxSetWorkingDirectory( TowxString(SlPaths::GetDataDir()) ); if ( m_process == 0 ) { m_process = new SpringProcess( *this ); } m_process->Create(); m_process->SetCommand(TowxString(cmd), params ); m_process->Run(); m_running = true; GlobalEvent::Send(GlobalEvent::OnSpringStarted); return true; }
wxThread::ExitCode WebServerThread::Entry() { // Get user setting int webserverPort = Model_Setting::instance().GetIntSetting("WEBSERVERPORT", 8080); const wxString& strPort = wxString::Format("%d", webserverPort); // Create and configure the server struct mg_server *server = mg_create_server(nullptr, ev_handler); mg_set_option(server, "listening_port", strPort.mb_str()); mg_set_option(server, "document_root", wxFileName(mmex::getReportIndex()).GetPath().mb_str()); wxSetWorkingDirectory(mg_get_option(server, "document_root")); // Serve requests while (IsAlive()) { mg_poll_server(server, 1000); } // Cleanup, and free server instance mg_destroy_server(&server); return (wxThread::ExitCode)0; }
/* * Read a EXCELLON file. * Gerber classes are used because there is likeness between Gerber files * and Excellon files * DCode can easily store T code (tool size) as round (or oval) shape * Drill commands are similar to flashed gerber items * Routing commands are similar to Gerber polygons * coordinates have the same format as Gerber, can be given in: * decimal format (i.i. floating notation format) * integer 2.4 format in imperial units, * integer 3.2 or 3.3 format (metric units). */ bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; int layer = getActiveLayer(); // current layer used in GerbView if( g_GERBER_List[layer] == NULL ) { g_GERBER_List[layer] = new EXCELLON_IMAGE( this, layer ); } EXCELLON_IMAGE* drill_Layer = (EXCELLON_IMAGE*) g_GERBER_List[layer]; ClearMessageList(); /* Read the gerber file */ FILE * file = wxFopen( aFullFileName, wxT( "rt" ) ); if( file == NULL ) { msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) ); DisplayError( this, msg, 10 ); return false; } wxString path = wxPathOnly( aFullFileName ); if( path != wxEmptyString ) wxSetWorkingDirectory( path ); bool success = drill_Layer->Read_EXCELLON_File( file, aFullFileName ); // Display errors list if( m_Messages.size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _("Files not found") ); dlg.ListSet( m_Messages ); dlg.ShowModal(); } return success; }
void CShowDescriptionListDlg::SaveAs() { int err, i; CBaseObject * pObj; CStr S(128); wxString CurrentDir = wxGetCwd(); wxFileDialog dialog(GetParent(), wxT("Save current text"), wxT(""), wxT(""), wxT(SZ_ALL_FILES), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); err = dialog.ShowModal(); wxSetWorkingDirectory(CurrentDir); if (wxID_OK == err) { CFileWriter F; if (F.Open(dialog.GetPath().mb_str())) { for (i=0; i<m_pItems->Count(); i++) { pObj = (CBaseObject*)m_pItems->At(i); S = pObj->Description; S.TrimRight(TRIM_ALL); S << EOL_FILE; F.WriteBuf(S.GetData(), S.GetLength()); } F.Close(); } else wxMessageBox(wxT("Can not open file")); } }
//Helper bool SaveAbstractLayer(vtAbstractLayer *alay, bool bAskFilename) { vtFeatureSet *fset = alay->GetFeatureSet(); vtString fname = fset->GetFilename(); if (bAskFilename) { // save current directory wxString path = wxGetCwd(); wxString default_file(StartOfFilename(fname), wxConvUTF8); wxString default_dir(ExtractPath(fname, false), wxConvUTF8); EnableContinuousRendering(false); wxFileDialog saveFile(NULL, _("Save Abstract Data"), default_dir, default_file, FSTRING_SHP, wxFD_SAVE); bool bResult = (saveFile.ShowModal() == wxID_OK); EnableContinuousRendering(true); if (!bResult) { wxSetWorkingDirectory(path); // restore return false; } wxString str = saveFile.GetPath(); fname = str.mb_str(wxConvUTF8); fset->SetFilename(fname); } bool success = fset->SaveToSHP(fname); if (success) alay->SetModified(false); else wxMessageBox(_("Couldn't save layer.")); return success; }
wxThread::ExitCode WebServerThread::Entry() { // Get user setting int webserverPort = Model_Setting::instance().GetIntSetting("WEBSERVERPORT", 8080); const wxString& strPort = wxString::Format("%d", webserverPort); // Create and configure the server struct mg_mgr mgr; mg_mgr_init(&mgr, NULL); struct mg_connection* nc = mg_bind(&mgr, strPort.c_str(), ev_handler); if (nc == nullptr) { wxLogDebug(wxString::Format("mg_bind(%s) failed", strPort)); mg_mgr_free(&mgr); return (wxThread::ExitCode)-1; } mg_set_protocol_http_websocket(nc); std::string document_root(wxFileName(mmex::getReportIndex()).GetPath().c_str()); s_http_server_opts.document_root = document_root.c_str(); s_http_server_opts.enable_directory_listing = "yes"; wxSetWorkingDirectory(wxString(s_http_server_opts.document_root)); // Serve requests while (IsAlive()) { mg_mgr_poll(&mgr, 1000); } // Cleanup, and free server instance mg_mgr_free(&mgr); return nullptr; }
int wxDirDialog::ShowModal() { WX_HOOK_MODAL_DIALOG(); wxWindow* const parent = GetParent(); WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL; // Use IFileDialog under new enough Windows, it's more user-friendly. int rc; #if wxUSE_IFILEDIALOG // While the new dialog is available under Vista, it may return a wrong // path there (see http://support.microsoft.com/kb/969885/en-us), so we // don't use it there by default. We could improve the version test to // allow its use if the comdlg32.dll version is greater than 6.0.6002.22125 // as this means that the hotfix correcting this bug is installed. if ( wxGetWinVersion() > wxWinVersion_Vista ) { rc = ShowIFileDialog(hWndParent); } else { rc = wxID_NONE; } if ( rc == wxID_NONE ) #endif // wxUSE_IFILEDIALOG { rc = ShowSHBrowseForFolder(hWndParent); } // change current working directory if asked so if ( rc == wxID_OK && HasFlag(wxDD_CHANGE_DIR) ) wxSetWorkingDirectory(m_path); return rc; }
int SelectDirDialog::ShowModal() { wxWindow *parent = GetParent(); BROWSEINFO bi; bi.hwndOwner = parent ? GetHwndOf(parent) : NULL; bi.pidlRoot = NULL; bi.pszDisplayName = NULL; // Please don't change this without checking it compiles // with eVC++ first. bi.lpszTitle = m_message.c_str(); bi.ulFlags = BIF_RETURNONLYFSDIRS; bi.lpfn = BrowseCallbackProc; bi.lParam = (LPARAM)this; // param for the callback // bi.ulFlags |= BIF_EDITBOX; // do show the dialog wxItemIdList pidl(SHBrowseForFolder(&bi)); wxItemIdList::Free((LPITEMIDLIST)bi.pidlRoot); if ( !pidl ) { // Cancel button pressed return wxID_CANCEL; } m_path = pidl.GetPath(); // change current working directory if asked so if (HasFlag(wxDD_CHANGE_DIR)) wxSetWorkingDirectory(m_path); return m_path.empty() ? wxID_CANCEL : wxID_OK; }
void wxGenericFileDialog::HandleAction( const wxString &fn ) { if (ignoreChanges) return; wxString filename( fn ); wxString dir = m_list->GetDir(); if (filename.empty()) return; if (filename == wxT(".")) return; // "some/place/" means they want to chdir not try to load "place" bool want_dir = filename.Last() == wxFILE_SEP_PATH; if (want_dir) filename = filename.RemoveLast(); if (filename == wxT("..")) { ignoreChanges = true; m_list->GoToParentDir(); m_list->SetFocus(); UpdateControls(); ignoreChanges = false; return; } #ifdef __UNIX__ if (filename == wxT("~")) { ignoreChanges = true; m_list->GoToHomeDir(); m_list->SetFocus(); UpdateControls(); ignoreChanges = false; return; } if (filename.BeforeFirst(wxT('/')) == wxT("~")) { filename = wxString(wxGetUserHome()) + filename.Remove(0, 1); } #endif // __UNIX__ if (!(m_dialogStyle & wxSAVE)) { if ((filename.Find(wxT('*')) != wxNOT_FOUND) || (filename.Find(wxT('?')) != wxNOT_FOUND)) { if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND) { wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR ); return; } m_list->SetWild( filename ); return; } } if (!IsTopMostDir(dir)) dir += wxFILE_SEP_PATH; if (!wxIsAbsolutePath(filename)) { dir += filename; filename = dir; } if (wxDirExists(filename)) { ignoreChanges = true; m_list->GoToDir( filename ); UpdateControls(); ignoreChanges = false; return; } // they really wanted a dir, but it doesn't exist if (want_dir) { wxMessageBox(_("Directory doesn't exist."), _("Error"), wxOK | wxICON_ERROR ); return; } // append the default extension to the filename if it doesn't have any // // VZ: the logic of testing for !wxFileExists() only for the open file // dialog is not entirely clear to me, why don't we allow saving to a // file without extension as well? if ( !(m_dialogStyle & wxOPEN) || !wxFileExists(filename) ) { filename = AppendExtension(filename, m_filterExtension); } // check that the file [doesn't] exist if necessary if ( (m_dialogStyle & wxSAVE) && (m_dialogStyle & wxOVERWRITE_PROMPT) && wxFileExists( filename ) ) { wxString msg; msg.Printf( _("File '%s' already exists, do you really want to overwrite it?"), filename.c_str() ); if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES) return; } else if ( (m_dialogStyle & wxOPEN) && (m_dialogStyle & wxFILE_MUST_EXIST) && !wxFileExists(filename) ) { wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK | wxICON_ERROR ); } SetPath( filename ); // change to the directory where the user went if asked if ( m_dialogStyle & wxCHANGE_DIR ) { wxString cwd; wxSplitPath(filename, &cwd, NULL, NULL); if ( cwd != wxGetCwd() ) { wxSetWorkingDirectory(cwd); } } wxCommandEvent event; wxDialog::OnOK(event); }
/*static*/ IProcess* WinProcessImpl::Execute(wxEvtHandler *parent, const wxString& cmd, wxString &errMsg, IProcessCreateFlags flags, const wxString &workingDir, IProcessCallback* cb) { SECURITY_ATTRIBUTES saAttr; BOOL fSuccess; MyDirGuard dg; wxString wd(workingDir); if (workingDir.IsEmpty()) { wd = wxGetCwd(); } wxSetWorkingDirectory( wd ); // Set the bInheritHandle flag so pipe handles are inherited. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; WinProcessImpl *prc = new WinProcessImpl(parent); prc->m_callback = cb; prc->m_flags = flags; // The steps for redirecting child process's STDOUT: // 1. Save current STDOUT, to be restored later. // 2. Create anonymous pipe to be STDOUT for child process. // 3. Set STDOUT of the parent process to be write handle to // the pipe, so it is inherited by the child process. // 4. Create a noninheritable duplicate of the read handle and // close the inheritable read handle. // Save the handle to the current STDOUT. prc->hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); // Create a pipe for the child process's STDOUT. if ( !CreatePipe( &prc->hChildStdoutRd, &prc->hChildStdoutWr, &saAttr, 0) ) { delete prc; return NULL; } // Set a write handle to the pipe to be STDOUT. if ( !SetStdHandle(STD_OUTPUT_HANDLE, prc->hChildStdoutWr) ) { delete prc; return NULL; } // Create noninheritable read handle and close the inheritable read handle. fSuccess = DuplicateHandle( GetCurrentProcess(), prc->hChildStdoutRd, GetCurrentProcess(), &prc->hChildStdoutRdDup , 0, FALSE, DUPLICATE_SAME_ACCESS ); if ( !fSuccess ) { delete prc; return NULL; } CloseHandle( prc->hChildStdoutRd ); // The steps for redirecting child process's STDERR: // 1. Save current STDERR, to be restored later. // 2. Create anonymous pipe to be STDERR for child process. // 3. Set STDERR of the parent process to be write handle to // the pipe, so it is inherited by the child process. // 4. Create a noninheritable duplicate of the read handle and // close the inheritable read handle. // Save the handle to the current STDERR. prc->hSaveStderr = GetStdHandle(STD_ERROR_HANDLE); // Create a pipe for the child process's STDERR. if ( !CreatePipe( &prc->hChildStderrRd, &prc->hChildStderrWr, &saAttr, 0) ) { delete prc; return NULL; } // Set a write handle to the pipe to be STDERR. if ( !SetStdHandle(STD_ERROR_HANDLE, prc->hChildStderrWr) ) { delete prc; return NULL; } // Create noninheritable read handle and close the inheritable read handle. fSuccess = DuplicateHandle( GetCurrentProcess(), prc->hChildStderrRd, GetCurrentProcess(), &prc->hChildStderrRdDup , 0, FALSE, DUPLICATE_SAME_ACCESS ); if ( !fSuccess ) { delete prc; return NULL; } CloseHandle( prc->hChildStderrRd ); // The steps for redirecting child process's STDIN: // 1. Save current STDIN, to be restored later. // 2. Create anonymous pipe to be STDIN for child process. // 3. Set STDIN of the parent to be the read handle to the // pipe, so it is inherited by the child process. // 4. Create a noninheritable duplicate of the write handle, // and close the inheritable write handle. // Save the handle to the current STDIN. prc->hSaveStdin = GetStdHandle(STD_INPUT_HANDLE); // Create a pipe for the child process's STDIN. if ( !CreatePipe(&prc->hChildStdinRd, &prc->hChildStdinWr, &saAttr, 0) ) { delete prc; return NULL; } // Set a read handle to the pipe to be STDIN. if ( !SetStdHandle(STD_INPUT_HANDLE, prc->hChildStdinRd) ) { delete prc; return NULL; } // Duplicate the write handle to the pipe so it is not inherited. fSuccess = DuplicateHandle(GetCurrentProcess(), prc->hChildStdinWr, GetCurrentProcess(), &prc->hChildStdinWrDup, 0, FALSE, // not inherited DUPLICATE_SAME_ACCESS ); if ( !fSuccess ) { delete prc; return NULL; } CloseHandle(prc->hChildStdinWr); // Execute the child process STARTUPINFO siStartInfo; // Set up members of STARTUPINFO structure. ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) ); siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; ; siStartInfo.hStdInput = prc->hChildStdinRd; siStartInfo.hStdOutput = prc->hChildStdoutWr; siStartInfo.hStdError = prc->hChildStderrWr; // Set the window to hide siStartInfo.wShowWindow = flags & IProcessCreateConsole ? SW_SHOW : SW_HIDE; DWORD creationFlags = flags & IProcessCreateConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW; if(flags & IProcessCreateWithHiddenConsole) { siStartInfo.wShowWindow = SW_HIDE; creationFlags = CREATE_NEW_CONSOLE|CREATE_NEW_PROCESS_GROUP; } BOOL ret = CreateProcess( NULL, cmd.wchar_str(), // shell line execution command NULL, // process security attributes NULL, // primary thread security attributes TRUE, // handles are inherited creationFlags, // creation flags NULL, // use parent's environment NULL, // CD to tmp dir &siStartInfo, // STARTUPINFO pointer &prc->piProcInfo); // receives PROCESS_INFORMATION if ( ret ) { prc->dwProcessId = prc->piProcInfo.dwProcessId; } else { int err = GetLastError(); wxUnusedVar(err); delete prc; return NULL; } // After process creation, restore the saved STDIN and STDOUT. if ( !SetStdHandle(STD_INPUT_HANDLE, prc->hSaveStdin) ) { delete prc; return NULL; } if ( !SetStdHandle(STD_OUTPUT_HANDLE, prc->hSaveStdout) ) { delete prc; return NULL; } if ( !SetStdHandle(STD_OUTPUT_HANDLE, prc->hSaveStderr) ) { delete prc; return NULL; } if ( prc->m_flags & IProcessCreateConsole || prc->m_flags & IProcessCreateWithHiddenConsole ) { ConsoleAttacher ca(prc->GetPid()); if ( ca.isAttached ) { freopen("CONOUT$","wb", stdout); // reopen stout handle as console window output freopen("CONOUT$","wb", stderr); // reopen stderr handle as console window output } } prc->SetPid( prc->dwProcessId ); prc->StartReaderThread(); return prc; }
void ToolsPlus::OnRunTarget(wxCommandEvent& event) { int ID=event.GetId(); wxString commandstr; wxString consolename; wxString workingdir; bool windowed=false; bool console=false; if (ID>=ID_ContextMenu_0&&ID<=ID_ContextMenu_49) { m_interpnum=m_contextvec[ID-ID_ContextMenu_0]; commandstr=m_ic.interps[m_interpnum].command; consolename=m_ic.interps[m_interpnum].name; windowed=(m_ic.interps[m_interpnum].mode==_("W")); console=(m_ic.interps[m_interpnum].mode==_("C")); workingdir=m_ic.interps[m_interpnum].wdir; } else if (ID>=ID_SubMenu_0&&ID<=ID_SubMenu_49) { m_interpnum=ID-ID_SubMenu_0; commandstr=m_ic.interps[m_interpnum].command; consolename=m_ic.interps[m_interpnum].name; windowed=(m_ic.interps[m_interpnum].mode==_("W")); console=(m_ic.interps[m_interpnum].mode==_("C")); workingdir=m_ic.interps[m_interpnum].wdir; m_wildcard=m_ic.interps[m_interpnum].wildcards; if (m_ic.interps[m_interpnum].command.Find(_("$file"))>0 || m_ic.interps[m_interpnum].command.Find(_("$path"))>0) { m_RunTarget=wxEmptyString; EditorManager* edMan = Manager::Get()->GetEditorManager(); if (edMan && edMan->GetActiveEditor() && edMan->GetActiveEditor()->GetFilename()) { wxFileName activefile(edMan->GetActiveEditor()->GetFilename()); wxString filename=activefile.GetFullPath(); wxString name=activefile.GetFullName(); if (WildCardListMatch(m_ic.interps[m_interpnum].wildcards,name)) m_RunTarget=filename; } if (m_RunTarget==wxEmptyString) OnSetTarget(event); if (!wxFileName::FileExists(m_RunTarget)) { LogMessage(_("Tools Plus plugin: ")+m_RunTarget+_(" not found")); return; } } if (m_ic.interps[m_interpnum].command.Find(_("$dir"))>0) { OnSetDirTarget(event); if (!wxFileName::DirExists(m_RunTarget)) { LogMessage(_("Tools Plus plugin: ")+m_RunTarget+_(" not found")); return; } if (m_RunTarget==_T("")) return; } if (m_ic.interps[m_interpnum].command.Find(_("$mpaths"))>0) { OnSetMultiTarget(event); if (m_RunTarget==_T("")) return; } } else { LogMessage(wxString::Format(_("WARNING: Unprocessed Tools Plus Menu Message: ID %i, IDbase %i, IDend %i, num items on menu %i"),ID,ID_ContextMenu_0,ID_ContextMenu_49,(int)m_contextvec.size())); return; } m_RunTarget.Replace(_T("*"),_T(" ")); bool setdir=true; commandstr.Replace(_("$file"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$relfile"),wxFileName(m_RunTarget).GetFullName()); commandstr.Replace(_("$fname"),wxFileName(m_RunTarget).GetName()); commandstr.Replace(_("$fext"),wxFileName(m_RunTarget).GetExt()); commandstr.Replace(_("$dir"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$reldir"),wxFileName(m_RunTarget).GetFullName()); commandstr.Replace(_("$path"),wxFileName(m_RunTarget).GetShortPath()); commandstr.Replace(_("$relpath"),wxFileName(m_RunTarget).GetFullPath()); if (commandstr.Replace(_("$mpaths"),m_RunTarget)>0) setdir=false; // substitute user prompted values in the format: $inputstr{Enter your message} int promptind=commandstr.Find(_("$inputstr{")); wxString substitution; while (promptind>=0) { int promptend=commandstr.Mid(promptind+10).Find(_("}")); if (promptend<=0) { cbMessageBox(_("Malformed $inputstr in command line -- no closing '}' found: ")+commandstr); return; } else promptend++; wxTextEntryDialog ted(NULL,commandstr.Mid(promptind+10,promptend-1),consolename,_T(""),wxOK|wxCANCEL); if (ted.ShowModal()==wxID_OK) substitution=ted.GetValue(); else return; commandstr=commandstr.Left(promptind)+substitution+commandstr.Mid(promptind+10+promptend); int nextind=commandstr.Mid(promptind+substitution.Len()).Find(_("$inputstr")); if (nextind>=0) promptind+=nextind+substitution.Len(); else promptind=-1; } commandstr.Replace(_("$interpreter"),wxFileName(m_ic.interps[m_interpnum].command).GetShortPath()); workingdir.Replace(_("$parentdir"),wxFileName(m_RunTarget).GetPath()); if (wxFileName::DirExists(m_RunTarget)) workingdir.Replace(_("$dir"),wxFileName(m_RunTarget).GetFullPath()); if (Manager::Get()->GetMacrosManager()) { Manager::Get()->GetMacrosManager()->RecalcVars(0, 0, 0); // hack to force-update macros Manager::Get()->GetMacrosManager()->ReplaceMacros(commandstr); Manager::Get()->GetMacrosManager()->ReplaceMacros(workingdir); } wxString olddir=wxGetCwd(); if (setdir && workingdir!=_T("")) { if (!wxSetWorkingDirectory(workingdir)) { LogMessage(_("Tools Plus Plugin: Can't change to working directory to ")+workingdir); return; } } LogMessage(wxString::Format(_("Launching '%s': %s (in %s)"), consolename.c_str(), commandstr.c_str(), workingdir.c_str())); if (windowed) { wxArrayString astr; m_shellmgr->LaunchProcess(commandstr,consolename,_("Piped Process Control"),astr); ShowConsole(); } else if (console) { wxString cmdline; #ifndef __WXMSW__ // for non-win platforms, use m_ConsoleTerm to run the console app wxString term = Manager::Get()->GetConfigManager(_T("app"))->Read(_T("/console_terminal"), DEFAULT_CONSOLE_TERM); term.Replace(_T("$TITLE"), _T("'") + consolename + _T("'")); cmdline<< term << _T(" "); #define CONSOLE_RUNNER "cb_console_runner" #else #define CONSOLE_RUNNER "cb_console_runner.exe" #endif wxString baseDir = ConfigManager::GetExecutableFolder(); if (wxFileExists(baseDir + wxT("/" CONSOLE_RUNNER))) cmdline << baseDir << wxT("/" CONSOLE_RUNNER " "); cmdline<<commandstr; if (!wxExecute(cmdline)) cbMessageBox(_("Command Launch Failed: ")+commandstr); } else { if (!wxExecute(commandstr)) cbMessageBox(_("Command Launch Failed: ")+commandstr); } wxSetWorkingDirectory(olddir); }
~MyDirGuard() { wxSetWorkingDirectory(_d); }
bool DolphinApp::OnInit() { InitLanguageSupport(); // Declarations and definitions bool UseDebugger = false; bool UseLogger = false; bool selectVideoBackend = false; bool selectAudioEmulation = false; wxString videoBackendName; wxString audioEmulationName; #if wxUSE_CMDLINE_PARSER // Parse command lines wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, wxS("h"), wxS("help"), _("Show this help message"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_SWITCH, wxS("d"), wxS("debugger"), _("Opens the debugger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("l"), wxS("logger"), _("Opens the logger"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("e"), wxS("exec"), _("Loads the specified file (DOL,ELF,GCM,ISO,WAD)"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_SWITCH, wxS("b"), wxS("batch"), _("Exit Dolphin with emulator"), wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("V"), wxS("video_backend"), _("Specify a video backend"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, wxS("A"), wxS("audio_emulation"), _("Low level (LLE) or high level (HLE) audio"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_NONE, 0 } }; // Gets the command line parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); if (parser.Parse() != 0) { return false; } UseDebugger = parser.Found(wxT("debugger")); UseLogger = parser.Found(wxT("logger")); LoadFile = parser.Found(wxT("exec"), &FileToLoad); BatchMode = parser.Found(wxT("batch")); selectVideoBackend = parser.Found(wxT("video_backend"), &videoBackendName); // TODO: This currently has no effect. Implement or delete. selectAudioEmulation = parser.Found(wxT("audio_emulation"), &audioEmulationName); #endif // wxUSE_CMDLINE_PARSER #if defined _DEBUG && defined _WIN32 int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF; _CrtSetDbgFlag(tmpflag); #endif // Register message box and translation handlers RegisterMsgAlertHandler(&wxMsgAlert); RegisterStringTranslator(&wxStringTranslator); // "ExtendedTrace" looks freakin dangerous!!! #ifdef _WIN32 EXTENDEDTRACEINITIALIZE("."); SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); #elif wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions(true); #endif // TODO: if First Boot if (!cpu_info.bSSE2) { PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n" "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n" "Sayonara!\n"); return false; } #ifdef _WIN32 if (!wxSetWorkingDirectory(wxString(File::GetExeDirectory().c_str(), *wxConvCurrent))) { INFO_LOG(CONSOLE, "set working directory failed"); } #else //create all necessary directories in user directory //TODO : detect the revision and upgrade where necessary File::CopyDir(std::string(SHARED_USER_DIR GAMECONFIG_DIR DIR_SEP), File::GetUserPath(D_GAMECONFIG_IDX)); File::CopyDir(std::string(SHARED_USER_DIR MAPS_DIR DIR_SEP), File::GetUserPath(D_MAPS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR SHADERS_DIR DIR_SEP), File::GetUserPath(D_SHADERS_IDX)); File::CopyDir(std::string(SHARED_USER_DIR WII_USER_DIR DIR_SEP), File::GetUserPath(D_WIIUSER_IDX)); File::CopyDir(std::string(SHARED_USER_DIR OPENCL_DIR DIR_SEP), File::GetUserPath(D_OPENCL_IDX)); if (!File::Exists(File::GetUserPath(D_CONFIG_IDX))) File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX)); if (!File::Exists(File::GetUserPath(D_GCUSER_IDX))) File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX)); if (!File::Exists(File::GetUserPath(D_CACHE_IDX))) File::CreateFullPath(File::GetUserPath(D_CACHE_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPDSP_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX)); if (!File::Exists(File::GetUserPath(D_DUMPTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_HIRESTEXTURES_IDX))) File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX)); if (!File::Exists(File::GetUserPath(D_SCREENSHOTS_IDX))) File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX)); if (!File::Exists(File::GetUserPath(D_STATESAVES_IDX))) File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX)); if (!File::Exists(File::GetUserPath(D_MAILLOGS_IDX))) File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX)); #endif LogManager::Init(); SConfig::Init(); VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoBackend && videoBackendName != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend = std::string(videoBackendName.mb_str()); VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend); // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers); int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX; int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY; int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth; int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight; // The following is not needed with X11, where window managers // do not allow windows to be created off the desktop. #ifdef _WIN32 // Out of desktop check HWND hDesktop = GetDesktopWindow(); RECT rc; GetWindowRect(hDesktop, &rc); if (rc.right < x + w || rc.bottom < y + h) x = y = wxDefaultCoord; #elif defined __APPLE__ if (y < 1) y = wxDefaultCoord; #endif main_frame = new CFrame((wxFrame*)NULL, wxID_ANY, wxString::FromAscii(svn_rev_str), wxPoint(x, y), wxSize(w, h), UseDebugger, BatchMode, UseLogger); SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. m_afterinit = new wxTimer(this, wxID_ANY); m_afterinit->Start(1, wxTIMER_ONE_SHOT); return true; }