bool CppCheck::AppExecute(const wxString& app, const wxString& CommandLine, wxArrayString& Output, wxArrayString& Errors) { wxWindowDisabler disableAll; wxBusyInfo running(_("Running ") + app + _T("... please wait (this may take several minutes)..."), Manager::Get()->GetAppWindow()); AppendToLog(CommandLine); if ( -1 == wxExecute(CommandLine, Output, Errors, wxEXEC_SYNC) ) { wxString msg = _("Failed to launch ") + app + _T(".\n" "Please setup the ") + app + _T(" executable accordingly in the settings\n" "and make sure its also in the path so ") + app + _T(" resources are found."); AppendToLog(msg); cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow()); if (!m_PATH.IsEmpty()) wxSetEnv(wxT("PATH"), m_PATH); // Restore return false; } int Count = Output.GetCount(); for (int idxCount = 0; idxCount < Count; ++idxCount) AppendToLog(Output[idxCount]); Count = Errors.GetCount(); for (int idxCount = 0; idxCount < Count; ++idxCount) AppendToLog(Errors[idxCount]); if (!m_PATH.IsEmpty()) wxSetEnv(wxT("PATH"), m_PATH); // Restore return true; }
RheiaEnvironementManager::RheiaEnvironementManager(): wxEvtHandler() { m_envars = RheiaManager::Get()->GetConfigurationManager( wxT("environement_manger") )->ReadStringStringMap( wxT("/variables") ); m_libpaths = RheiaManager::Get()->GetConfigurationManager( wxT("environement_manger") )->ReadArrayString( wxT("/libs") ); RheiaStringStringMap::iterator it = m_envars.begin(); for ( ; it != m_envars.end() ; ++it ) wxSetEnv( it->first , it->second ); for ( unsigned int i = 0; i < m_libpaths.GetCount() ; ++i ) { wxString env; #if defined( WIN32 ) wxGetEnv( wxT("PATH") , &env ); env += wxT(";") + m_libpaths[i]; wxSetEnv( wxT("PATH") , env ); #elif defined( LINUX ) wxGetEnv( wxT("LD_LIBRARY_PATH") , &env ); env += m_libpaths[i] + wxT(":"); wxSetEnv( wxT("LD_LIBRARY_PATH") , env ); #elif defined( MACOSX ) wxGetEnv( wxT("DYLD_LIBRARY_PATH") , &env ); env += m_libpaths[i] + wxT(":"); wxSetEnv( wxT("DYLD_LIBRARY_PATH") , env ); #endif } RheiaEventsManager* pm = RheiaEventsManager::Get(); pm->RegisterEventMethod(RheiaEVT_FRAME_CLOSING, new RheiaEventFunctor<RheiaEnvironementManager>(this, RheiaFrameEventHandler(RheiaEnvironementManager::OnCloseFrame))); }
bool RheiaEnvironementManager::AddPath( const wxString& path ) { int index = m_libpaths.Index( path ); if ( index != wxNOT_FOUND ) return false; m_libpaths.Add( path ); RheiaManager::Get()->GetConfigurationManager( wxT("environement_manger") )->Write( wxT("/libs") , m_libpaths ); wxString env; #if defined( WIN32 ) wxGetEnv( wxT("PATH") , &env ); env += wxT(";") + path; wxSetEnv( wxT("PATH") , env ); #elif defined( LINUX ) wxGetEnv( wxT("LD_LIBRARY_PATH") , &env ); env += path + wxT(":"); wxSetEnv( wxT("LD_LIBRARY_PATH") , env ); #elif defined( MACOSX ) wxGetEnv( wxT("DYLD_LIBRARY_PATH") , &env ); env += path + wxT(":"); wxSetEnv( wxT("DYLD_LIBRARY_PATH") , env ); #endif return true; }
//--------------------------------------------------------- bool CSG_Module_Library::Create(const CSG_String &File_Name) { Destroy(); TSG_PFNC_MLB_Initialize MLB_Initialize; TSG_PFNC_MLB_Get_Interface MLB_Get_Interface; wxString sPath; wxFileName fName(File_Name.c_str()); fName.MakeAbsolute(); m_File_Name = fName.GetFullPath(); //----------------------------------------------------- if( wxGetEnv(ENV_LIB_PATH, &sPath) && sPath.Length() > 0 ) { wxSetEnv(ENV_LIB_PATH, CSG_String::Format(SG_T("%s%c%s"), sPath.c_str(), ENV_LIB_SEPA, SG_File_Get_Path(m_File_Name).c_str())); } else { wxSetEnv(ENV_LIB_PATH, SG_File_Get_Path(m_File_Name).c_str()); } //----------------------------------------------------- if( m_pLibrary->Load(m_File_Name.c_str()) && (MLB_Get_Interface = (TSG_PFNC_MLB_Get_Interface) m_pLibrary->GetSymbol(SYMBOL_MLB_Get_Interface)) != NULL && (MLB_Initialize = (TSG_PFNC_MLB_Initialize) m_pLibrary->GetSymbol(SYMBOL_MLB_Initialize) ) != NULL && MLB_Initialize(m_File_Name) ) { m_pInterface = MLB_Get_Interface(); } //----------------------------------------------------- if( sPath.Length() > 0 ) { wxSetEnv(ENV_LIB_PATH, sPath); } else { wxUnsetEnv(ENV_LIB_PATH); } //----------------------------------------------------- if( Get_Count() > 0 ) { for(int i=0; i<Get_Count(); i++) Get_Module(i)->Set_Managed(false); return( true ); } Destroy(); return( false ); }
void CrtTestCase::SetGetEnv() { wxString val; wxSetEnv(_T("TESTVAR"), _T("value")); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) == true ); CPPUNIT_ASSERT( val == _T("value") ); wxSetEnv(_T("TESTVAR"), _T("something else")); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) ); CPPUNIT_ASSERT( val == _T("something else") ); CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) ); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false ); }
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()) { // PRL: I suspect Bug1257 -- Crash when enabling Amplio2 -- is the fault of a timing- // dependent multi-threading bug in the Amplio2 library itself, in case the unload of the .dll // comes too soon after the load. I saw the bug in Release builds but not Debug. // A sleep of even 1 ms was enough to fix the problem for me, but let's be even more generous. ::wxMilliSleep(10); lib.Unload(); } wxSetWorkingDirectory(saveOldCWD); hadpath ? wxSetEnv(wxT("PATH"), envpath) : wxUnsetEnv(wxT("PATH")); return index > 0; }
bool EDA_APP::SetFootprintLibTablePath() { wxString path; wxString kisysmod( wxT( KISYSMOD ) ); // Set the KISYSMOD environment variable for the current process if it is not already // defined in the user's environment. This is required to expand the global footprint // library table paths. if( wxGetEnv( kisysmod, &path ) && wxFileName::DirExists( path ) ) return true; // Set the KISYSMOD environment variable to the path defined in the user's configuration // if it is defined and the path exists. if( m_commonSettings->Read( kicadFpLibPath, &path ) && wxFileName::DirExists( path ) ) { wxSetEnv( kisysmod, path ); return true; } // Attempt to determine where the footprint libraries were installed using the legacy // library search paths. if( !GetLibraryPathList().IsEmpty() ) { unsigned modFileCount = 0; wxString bestPath; wxArrayString tmp; for( unsigned i = 0; i < GetLibraryPathList().GetCount(); i++ ) { unsigned cnt = wxDir::GetAllFiles( GetLibraryPathList()[i], &tmp, wxT( "*.mod" ), wxDIR_FILES ); if( cnt > modFileCount ) { modFileCount = cnt; bestPath = GetLibraryPathList()[i]; } } if( modFileCount != 0 ) { wxSetEnv( kisysmod, bestPath ); return true; } } return false; }
AutoDetectResult CompilerOW::AutoDetectInstallationDir() { /* Following code is Not necessary as OpenWatcom does not write to Registry anymore */ /*wxRegKey key; // defaults to HKCR key.SetName(wxT("HKEY_LOCAL_MACHINE\\Software\\Open Watcom\\c_1.0")); if (key.Open()) // found; read it key.QueryValue(wxT("Install Location"), m_MasterPath);*/ if (m_MasterPath.IsEmpty()) // just a guess; the default installation dir m_MasterPath = wxT("C:\\watcom"); if (!m_MasterPath.IsEmpty()) { AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h")); AddIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt")); AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386")); AddLibDir(m_MasterPath + wxFILE_SEP_PATH + wxT("lib386") + wxFILE_SEP_PATH + wxT("nt")); AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h")); AddResourceIncludeDir(m_MasterPath + wxFILE_SEP_PATH + wxT("h") + wxFILE_SEP_PATH + wxT("nt")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt")); m_ExtraPaths.Add(m_MasterPath + wxFILE_SEP_PATH + wxT("binw")); } wxSetEnv(wxT("WATCOM"), m_MasterPath); return wxFileExists(m_MasterPath + wxFILE_SEP_PATH + wxT("binnt") + wxFILE_SEP_PATH + m_Programs.C) ? adrDetected : adrGuessed; }
bool Springsettings::OnInit() { wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") ); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName(_T("SpringSettings")); const wxString configdir = TowxString(SlPaths::GetConfigfileDir()); if ( !wxDirExists(configdir) ) wxMkdir(configdir); if (!m_crash_handle_disable) { #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions( true ); #endif #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT) //this undocumented function acts as a workaround for the dysfunctional // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler ) SetUnhandledExceptionFilter(filter); #endif } //initialize all loggers //TODO non-constant parameters wxLogChain* logchain = 0; wxLogWindow* loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, m_log_verbosity, logchain ); //this needs to called _before_ mainwindow instance is created #ifdef __WXMSW__ wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale"); #else #if defined(LOCALE_INSTALL_DIR) wxString path ( _T(LOCALE_INSTALL_DIR) ); #else // use a dummy name here, we're only interested in the base path wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages); path = path.Left( path.First(_T("noneWH") ) ); #endif #endif m_translationhelper = new wxTranslationHelper( GetAppName().Lower(), path ); SetSettingsStandAlone( true ); // configure unitsync paths before trying to load SlPaths::ReconfigureUnitsync(); //unitsync first load, NEEDS to be blocking LSL::usync().ReloadUnitSyncLib(); settings_frame* frame = new settings_frame(NULL,GetAppName()); SetTopWindow(frame); frame->Show(); if ( loggerwin ) { // we got a logwindow, lets set proper parent win loggerwin->GetFrame()->SetParent( frame ); } return true; }
/// Extend LIB_ENV_VAR list with the directory from which I came, prepending it. static void set_lib_env_var( const wxString& aAbsoluteArgv0 ) { // POLICY CHOICE 2: Keep same path, so that installer MAY put the // "subsidiary DSOs" in the same directory as the kiway top process modules. // A subsidiary shared library is one that is not a top level DSO, but rather // some shared library that a top level DSO needs to even be loaded. It is // a static link to a shared object from a top level DSO. // This directory POLICY CHOICE 2 is not the only dir in play, since LIB_ENV_VAR // has numerous path options in it, as does DSO searching on linux, windows, and OSX. // See "man ldconfig" on linux. What's being done here is for quick installs // into a non-standard place, and especially for Windows users who may not // know what the PATH environment variable is or how to set it. wxFileName fn( aAbsoluteArgv0 ); wxString ld_path( LIB_ENV_VAR ); wxString my_path = fn.GetPath(); wxString new_paths = PrePendPath( ld_path, my_path ); wxSetEnv( ld_path, new_paths ); #if defined(DEBUG) { wxString test; wxGetEnv( ld_path, &test ); printf( "LIB_ENV_VAR:'%s'\n", TO_UTF8( test ) ); } #endif }
bool wxApp::Initialize(int& argc, wxChar **argv) { #ifdef __DJGPP__ // VS: disable long filenames under DJGPP as the very first thing, // since SciTech MGL doesn't like them much... wxSetEnv(wxT("LFN"), wxT("N")); #endif // intialize MGL before creating wxFontsManager since it uses MGL funcs if ( MGL_init(".", NULL) == 0 ) { wxLogError(_("Cannot initialize SciTech MGL!")); return false; } // must do it before calling wxAppBase::Initialize(), because fonts are // needed by stock lists which are created there wxTheFontsManager = new wxFontsManager; if ( !wxAppBase::Initialize(argc, argv) ) { delete wxTheFontsManager; wxTheFontsManager = NULL; MGL_exit(); return false; } #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif return true; }
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) { // Compare paths, rather than inodes, to be less surprising to the user. // Create a temporary wxFileName to normalize the path wxFileName candidate_path( aFullPathAndName ); // Edge transitions only. This is what clears the project // data using the Clear() function. if( m_project_name.GetFullPath() != candidate_path.GetFullPath() ) { Clear(); // clear the data when the project changes. wxLogTrace( tracePathsAndFiles, "%s: old:'%s' new:'%s'", __func__, TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) ); m_project_name = aFullPathAndName; wxASSERT( m_project_name.IsAbsolute() ); wxASSERT( m_project_name.GetExt() == ProjectFileExtension ); // until multiple projects are in play, set an environment variable for the // the project pointer. { wxString path = m_project_name.GetPath(); wxSetEnv( PROJECT_VAR_NAME, path ); } } }
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; }
wxString CppCheck::GetAppExecutable(const wxString& app, const wxString& app_cfg) { ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("cppcheck")); wxString Executable = ConfigPanel::GetDefaultCppCheckExecutableName(); if (cfg) Executable = cfg->Read(app_cfg, Executable); Manager::Get()->GetMacrosManager()->ReplaceMacros(Executable); AppendToLog(wxString::Format(_("Executable ") + app + _T(": '%s'."), Executable.wx_str())); // Make sure file is accessible, otherwise add path to cppcheck to PATH envvar wxFileName fn(Executable); if (fn.IsOk() && fn.FileExists()) { wxString AppPath = fn.GetPath(); AppendToLog(wxString::Format(_("Path to ") + app + _T(": '%s'."), AppPath.wx_str())); if ( AppPath.Trim().IsEmpty() ) return Executable; // Nothing to do, lets hope it works and cppcheck is in the PATH bool PrependPath = true; wxString NewPathEnvVar = wxEmptyString; wxPathList PathList; PathList.AddEnvList(wxT("PATH")); for (size_t i=0; i<PathList.GetCount(); ++i) { wxString PathItem = PathList.Item(i); if ( PathItem.IsSameAs(AppPath, (platform::windows ? false : true)) ) { AppendToLog(_("Executable of cppcheck is in the path.")); PrependPath = false; break; // Exit for-loop } if ( !NewPathEnvVar.IsEmpty() ) NewPathEnvVar << wxPATH_SEP; NewPathEnvVar << PathItem; } if (m_PATH.IsEmpty()) m_PATH = NewPathEnvVar; if (PrependPath) { NewPathEnvVar = NewPathEnvVar.Prepend(wxPATH_SEP); NewPathEnvVar = NewPathEnvVar.Prepend(AppPath); wxSetEnv(wxT("PATH"), NewPathEnvVar); // Don't care about return value AppendToLog(wxString::Format(_("Updated PATH environment to include path to ") + app + _T(": '%s' ('%s')."), AppPath.wx_str(), NewPathEnvVar.wx_str())); } } return Executable; }
bool RheiaEnvironementManager::Change( const wxString& name , const wxString& value ) { m_envars[name] = value; wxSetEnv( name , value ); RheiaManager::Get()->GetConfigurationManager( wxT("environement_manger") )->Write( wxT("/variables") , m_envars ); return true; }
void sysProcess::SetEnvironment(const wxArrayString &environment) { size_t i; for (i = 0 ; i < environment.GetCount() ; i++) { wxString str = environment.Item(i); wxSetEnv(str.BeforeFirst('='), str.AfterFirst('=')); } }
void CrtTestCase::SetGetEnv() { wxString val; wxSetEnv(_T("TESTVAR"), _T("value")); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) == true ); CPPUNIT_ASSERT( val == _T("value") ); wxSetEnv(_T("TESTVAR"), _T("something else")); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), &val) ); CPPUNIT_ASSERT( val == _T("something else") ); // this test doesn't work under Unix systems without setenv(): putenv() can // only be used to add or modify environment variables but not to unset // them #if !defined(__UNIX__) || defined(HAVE_SETENV) CPPUNIT_ASSERT( wxUnsetEnv(_T("TESTVAR")) ); CPPUNIT_ASSERT( wxGetEnv(_T("TESTVAR"), NULL) == false ); #endif }
void MainFrame::SetSystemTrayIcon(const wxString& icon, const wxString& tooltip) { if(CheckOption(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"))){ wxIcon i = wxIcon(icon,wxBITMAP_TYPE_ICO_RESOURCE,g_iconSize,g_iconSize); if(!m_systemTrayIcon->SetIcon(i,tooltip)){ etrace("system tray icon setup failed"); wxSetEnv(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"),wxT("0")); } } }
void EnvTestCase::GetSet() { const wxChar *var = wxT("wxTestVar"); wxString contents; CPPUNIT_ASSERT(!wxGetEnv(var, &contents)); CPPUNIT_ASSERT(contents.empty()); wxSetEnv(var, wxT("value for wxTestVar")); CPPUNIT_ASSERT(wxGetEnv(var, &contents)); CPPUNIT_ASSERT(contents == wxT("value for wxTestVar")); wxSetEnv(var, wxT("another value")); CPPUNIT_ASSERT(wxGetEnv(var, &contents)); CPPUNIT_ASSERT(contents == wxT("another value")); wxUnsetEnv(var); CPPUNIT_ASSERT(!wxGetEnv(var, &contents)); }
bool nsEnvVars::EnvvarApply(const wxString& key, const wxString& value) { #if defined(TRACE_ENVVARS) Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarApply"))); #endif // Replace all macros the user might have setup for the key wxString the_key = key; Manager::Get()->GetMacrosManager()->ReplaceMacros(the_key); if (the_key.Trim().IsEmpty()) return false; // Value: First, expand stuff like: // set PATH=%PATH%;C:\NewPath OR export PATH=$PATH:/new_path // After, replace all macros the user might have used in addition wxString value_set; bool is_set = wxGetEnv(the_key, &value_set); wxString the_value = value; if (is_set) { std::map<wxString,wxString>::iterator it = nsEnvVars::EnvVarsStack.find(the_key); if (it==nsEnvVars::EnvVarsStack.end()) // envvar not already on the stack nsEnvVars::EnvVarsStack[the_key] = value_set; // remember the old value // Avoid endless recursion if the value set contains e.g. $PATH, too if (nsEnvVars::EnvvarIsRecursive(the_key,the_value)) { if (nsEnvVars::EnvvarIsRecursive(the_key,value_set)) { EV_DBGLOG(_T("EnvVars: Setting environment variable '%s' failed " "due to unresolvable recursion."), the_key.wx_str()); return false; } // Restore original value in case of recursion before if (it!=nsEnvVars::EnvVarsStack.end()) value_set = nsEnvVars::EnvVarsStack[the_key]; // Resolve recursion now (if any) wxString recursion; if (platform::windows) recursion = _T("%")+the_key+_("%"); else recursion = _T("$")+the_key; the_value.Replace(recursion.wx_str(), value_set.wx_str()); } } // Replace all macros the user might have setup for the value Manager::Get()->GetMacrosManager()->ReplaceMacros(the_value); EV_DBGLOG(_T("EnvVars: Trying to set environment variable '%s' to value '%s'..."), the_key.wx_str(), the_value.wx_str()); if (!wxSetEnv(the_key, the_value)) // set the envvar as computed { EV_DBGLOG(_T("EnvVars: Setting environment variable '%s' failed."), the_key.wx_str()); return false; } return true; }// EnvvarApply
APP_KICAD(): wxApp() { // Disable proxy menu in Unity window manager. Only usual menubar works with wxWidgets (at least <= 3.1) // When the proxy menu menubar is enable, some important things for us do not work: menuitems UI events and shortcuts. wxString wm; if( wxGetEnv( wxT( "XDG_CURRENT_DESKTOP" ), &wm ) && wm.CmpNoCase( wxT( "Unity" ) ) == 0 ) { wxSetEnv ( wxT("UBUNTU_MENUPROXY" ), wxT( "0" ) ); } }
//right now this is equivalent to Job.cpp @ void MainFrame::OnStartJob(wxCommandEvent& event) void MainFrame::QueryClusters(wxCommandEvent& event){ wxString filtertext,itemtext; int id = event.GetId(); m_queryThread->m_qp = new udefrag_query_parameters(); WxTextCtrl1->Clear(); //Launched from Menu: if (id == ID_QueryClusters){ itemtext = m_filesList->GetListItem().GetText(); WxFilePickerCtrl1->SetPath(itemtext); ProcessCommandEvent(ID_SelectProperDrive); long i = m_filesList->GetFirstSelected(); while(i != -1){ wxString selitem = m_filesList->GetItemText(i); Utils::extendfiltertext(selitem,&filtertext); i = m_filesList->GetNextSelected(i); } } //Launched from Tab else if (id == ID_PERFORMQUERY){ itemtext = WxFilePickerCtrl1->GetPath(); Utils::extendfiltertext(itemtext,&filtertext); } //set the Analysis Mode to SINGLE file mode. // This probably can't work for all queries, but is fast. wxSetEnv(L"UD_CUT_FILTER",filtertext); m_queryThread->singlefile = TRUE; m_queryThread->m_flags |= UD_JOB_CONTEXT_MENU_HANDLER; m_queryThread->m_querypath = (wchar_t *)itemtext.fn_str(); m_queryThread->m_qp->path = m_queryThread->m_querypath; m_queryThread->m_letter = (char)(itemtext[0]); //find the drive-letter of the fragmented files tab. m_queryThread->m_mapSize = getmapsize(); switch(id){ case ID_QueryClusters: case ID_PERFORMQUERY: m_queryThread->m_qType = QUERY_GET_VCNLIST; break; case ID_QueryClusters+1: m_queryThread->m_qType = QUERY_GET_FREE_REGIONS; break; default: break; } m_busy = true; m_paused = false; m_stopped = false; m_queryThread->m_startquery = true; //BEGIN LAUNCH. }
void CrtTestCase::SetGetEnv() { #define TESTVAR_NAME wxT("WXTESTVAR") wxString val; wxSetEnv(TESTVAR_NAME, wxT("value")); CPPUNIT_ASSERT( wxGetEnv(TESTVAR_NAME, &val) ); CPPUNIT_ASSERT_EQUAL( "value", val ); CPPUNIT_ASSERT_EQUAL( "value", wxString(wxGetenv(TESTVAR_NAME)) ); wxSetEnv(TESTVAR_NAME, wxT("something else")); CPPUNIT_ASSERT( wxGetEnv(TESTVAR_NAME, &val) ); CPPUNIT_ASSERT_EQUAL( "something else", val ); CPPUNIT_ASSERT_EQUAL( "something else", wxString(wxGetenv(TESTVAR_NAME)) ); CPPUNIT_ASSERT( wxUnsetEnv(TESTVAR_NAME) ); CPPUNIT_ASSERT( !wxGetEnv(TESTVAR_NAME, NULL) ); CPPUNIT_ASSERT( !wxGetenv(TESTVAR_NAME) ); #undef TESTVAR_NAME }
void QMakePlugin::OnBuildStarting(clBuildEvent& event) { // call Skip() to allow the standard compilation to take place event.Skip(); QmakePluginData::BuildConfPluginData bcpd; wxString project = event.GetProjectName(); wxString config = event.GetConfigurationName(); if ( !DoGetData(project, config, bcpd) ) { return; } if ( !bcpd.m_enabled ) { return; } wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); if ( !p ) { return; } QMakeProFileGenerator generator(m_mgr, project, config); // regenrate the .pro file bool needRegeneration = generator.Generate(); wxString qmake_exe = m_conf->Read(wxString::Format(wxT("%s/qmake"), bcpd.m_qmakeConfig.c_str())); wxString qmakespec = m_conf->Read(wxString::Format(wxT("%s/qmakespec"), bcpd.m_qmakeConfig.c_str())); wxString qtdir = m_conf->Read(wxString::Format(wxT("%s/qtdir"), bcpd.m_qmakeConfig.c_str())); // Create qmake comand wxString qmake_exe_line; qmake_exe.Trim().Trim(false); qmakespec.Trim().Trim(false); // Set QTDIR DirSaver ds; { wxSetWorkingDirectory ( p->GetFileName().GetPath(wxPATH_GET_SEPARATOR|wxPATH_GET_VOLUME) ); wxSetEnv(wxT("QTDIR"), qtdir); qmake_exe_line << wxT("\"") << qmake_exe << wxT("\" -spec ") << qmakespec << wxT(" ") << generator.GetProFileName(); if ( needRegeneration ) { wxArrayString output; ProcUtils::SafeExecuteCommand(qmake_exe_line, output); } } }
bool RheiaEnvironementManager::Add( const wxString& name , const wxString& value ) { RheiaStringStringMap::iterator it = m_envars.find( name ); if ( it != m_envars.end() ) return false; m_envars[name] = value; wxSetEnv( name , value ); RheiaManager::Get()->GetConfigurationManager( wxT("environement_manger") )->Write( wxT("/variables") , m_envars ); return true; }
bool EDA_APP::OnInit() { wxFileName fn; PCB_EDIT_FRAME* frame = NULL; wxString msg; InitEDA_Appl( wxT( "Pcbnew" ), APP_PCBNEW_T ); #ifdef KICAD_SCRIPTING msg.Empty(); #ifdef __WINDOWS__ // force python environment under Windows: const wxString python_us("python27_us"); // Build our python path inside kicad wxString kipython = m_BinDir + python_us; // If our python install is existing inside kicad, use it if( wxDirExists( kipython ) ) { wxString ppath; if( !wxGetEnv( wxT( "PYTHONPATH" ), &ppath ) || !ppath.Contains( python_us ) ) { ppath << kipython << wxT("/pylib;"); ppath << kipython << wxT("/lib;"); ppath << kipython << wxT("/dll"); wxSetEnv( wxT( "PYTHONPATH" ), ppath ); DBG( std::cout << "set PYTHONPATH to " << TO_UTF8(ppath) << "\n"; ) // Add python executable path: wxGetEnv( wxT( "PATH" ), &ppath ); if( !ppath.Contains( python_us ) ) { kipython << wxT(";") << ppath; wxSetEnv( wxT( "PATH" ), kipython ); DBG( std::cout << "set PATH to " << TO_UTF8(kipython) << "\n"; ) }
bool PGM_BASE::SetLocalEnvVariable( const wxString& aName, const wxString& aValue ) { wxString env; // Check to see if the environment variable is already set. if( wxGetEnv( aName, &env ) ) { wxLogTrace( traceEnvVars, wxT( "Environment variable %s already set to %s." ), GetChars( aName ), GetChars( env ) ); return env == aValue; } wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ), GetChars( aName ), GetChars( aValue ) ); return wxSetEnv( aName, aValue ); }
void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap ) { m_local_env_vars.clear(); m_local_env_vars = aEnvVarMap; if( m_common_settings ) m_common_settings->DeleteGroup( pathEnvVariables ); saveCommonSettings(); // Overwrites externally defined environment variable until the next time the application // is run. for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it ) { wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ), GetChars( it->first ), GetChars( it->second.GetValue() ) ); wxSetEnv( it->first, it->second.GetValue() ); } }
void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) { m_project_name = aFullPathAndName; wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() ); #if 0 wxASSERT( m_project_name.GetExt() == ProjectFileExtension ) #else m_project_name.SetExt( ProjectFileExtension ); #endif // until multiple projects are in play, set an environment variable for the // the project pointer. { wxString path = m_project_name.GetPath(); // wxLogDebug( wxT( "Setting env %s to '%s'." ), PROJECT_VAR_NAME, GetChars( path ) ); wxSetEnv( PROJECT_VAR_NAME, path ); } }
bool ecUtils::AddToPath(const ecFileName & strFolder, bool bAtFront) { wxString strPath,strOldPath; if (wxGetEnv(wxT("PATH"), & strOldPath)) { // Place the user tools folders at the head or tail of the new path if(bAtFront) { strPath.Printf(wxT("%s;%s"), (const wxChar*) strFolder.ShortName(), (const wxChar*) strOldPath); } else { strPath.Printf(wxT("%s;%s"), (const wxChar*) strOldPath, (const wxChar*) strFolder.ShortName()); } } else { // unlikely, but ... strPath = strFolder; } return (TRUE == wxSetEnv(wxT("PATH"),strPath)); }