本文整理汇总了C++中wxSetEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ wxSetEnv函数的具体用法?C++ wxSetEnv怎么用?C++ wxSetEnv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxSetEnv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: running
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;
}
示例2: Destroy
//---------------------------------------------------------
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 );
}
示例3: wxSetEnv
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 );
}
示例4: f
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;
}
示例5: kisysmod
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;
}
示例6: wxT
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;
}
示例7: wxSetEnv
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;
}
示例8: set_lib_env_var
/// 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
}
示例9: candidate_path
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 );
}
}
}
示例10: f
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;
}
示例11: AppendToLog
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;
}
示例12: wxSetEnv
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('='));
}
}
示例13: wxSetEnv
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
}
示例14: wxIcon
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"));
}
}
}
示例15: wxT
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));
}