本文整理汇总了C++中wxGetEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetEnv函数的具体用法?C++ wxGetEnv怎么用?C++ wxGetEnv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxGetEnv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_pluckerhome_directory
// Looks up the root directory, as needed by get_plucker_directory.
// Don't use this function directly, use a get_plucker_directory() instead.
wxString get_pluckerhome_directory()
{
wxString pluckerhome_directory;
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__)
bool pluckerhome_exists;
pluckerhome_exists = wxGetEnv( wxT( "PLUCKERHOME" ), &pluckerhome_directory );
if ( ! pluckerhome_exists )
{
pluckerhome_directory = wxGetHomeDir() << wxT( "/.plucker" );
}
#endif
#ifdef __WXMAC__
bool pluckerhome_exists;
pluckerhome_exists = wxGetEnv( wxT( "PLUCKERHOME" ), &pluckerhome_directory );
if ( ! pluckerhome_exists )
{
pluckerhome_directory = wxGetHomeDir() << wxT( "/Library/Plucker" );
}
#endif
#ifdef __WXMSW__
bool pluckerhome_exists;
pluckerhome_exists = wxGetEnv( wxT( "PLUCKERHOME" ), &pluckerhome_directory );
if ( ! pluckerhome_exists )
{
pluckerhome_directory = wxGetHomeDir() << wxT( "/Application Data/Plucker" );
}
#endif
return pluckerhome_directory;
}
示例2: config
void Application::checkEnvironment()
{
wxString envVar;
if (wxGetEnv("FR_HOME", &envVar))
config().setHomePath(translatePathMacros(envVar));
if (wxGetEnv("FR_USER_HOME", &envVar))
config().setUserHomePath(translatePathMacros(envVar));
}
示例3: wxGetEnv
AutoDetectResult CompilerMSVC::AutoDetectInstallationDir()
{
wxString sep = wxFileName::GetPathSeparator();
// Read the VCToolkitInstallDir environment variable
wxGetEnv(_T("VCToolkitInstallDir"), &m_MasterPath);
if (m_MasterPath.IsEmpty())
{
// just a guess; the default installation dir
wxString Programs = _T("C:\\Program Files");
// what's the "Program Files" location
// TO DO : support 64 bit -> 32 bit apps are in "ProgramFiles(x86)"
// 64 bit apps are in "ProgramFiles"
wxGetEnv(_T("ProgramFiles"), &Programs);
m_MasterPath = Programs + _T("\\Microsoft Visual C++ Toolkit 2003");
}
if (!m_MasterPath.IsEmpty())
{
AddIncludeDir(m_MasterPath + sep + _T("include"));
AddLibDir(m_MasterPath + sep + _T("lib"));
#ifdef __WXMSW__
// add include dirs for MS Platform SDK too
wxRegKey key; // defaults to HKCR
key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\Win32SDK\\Directories"));
if (key.Exists() && key.Open(wxRegKey::Read))
{
wxString dir;
key.QueryValue(_T("Install Dir"), dir);
if (!dir.IsEmpty())
{
if (dir.GetChar(dir.Length() - 1) != '\\')
dir += sep;
AddIncludeDir(dir + _T("include"));
AddLibDir(dir + _T("lib"));
m_ExtraPaths.Add(dir + _T("bin"));
}
}
// add extra paths for "Debugging tools" too
key.SetName(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\DebuggingTools"));
if (key.Exists() && key.Open(wxRegKey::Read))
{
wxString dir;
key.QueryValue(_T("WinDbg"), dir);
if (!dir.IsEmpty())
{
if (dir.GetChar(dir.Length() - 1) == '\\')
dir.Remove(dir.Length() - 1, 1);
m_ExtraPaths.Add(dir);
}
}
#endif // __WXMSW__
}
return wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed;
}
示例4: 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 );
}
示例5: get_temp_dir
wxString
get_temp_dir() {
wxString temp_dir;
wxGetEnv(wxT("TMP"), &temp_dir);
if (temp_dir == wxEmptyString)
wxGetEnv(wxT("TEMP"), &temp_dir);
if ((temp_dir == wxEmptyString) && wxDirExists(wxT("/tmp")))
temp_dir = wxT("/tmp");
if (temp_dir != wxEmptyString)
temp_dir += wxT(PATHSEP);
return temp_dir;
}
示例6: GetKicadConfigPath
/*
* GetKicadConfigPath() is taken from KiCad's common.cpp source:
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2015 Wayne Stambaugh <[email protected]>
* Copyright (C) 1992-2015 KiCad Developers
*/
static wxString GetKicadConfigPath()
{
wxFileName cfgpath;
// From the wxWidgets wxStandardPaths::GetUserConfigDir() help:
// Unix: ~ (the home directory)
// Windows: "C:\Documents and Settings\username\Application Data"
// Mac: ~/Library/Preferences
cfgpath.AssignDir( wxStandardPaths::Get().GetUserConfigDir() );
#if !defined( __WINDOWS__ ) && !defined( __WXMAC__ )
wxString envstr;
if( !wxGetEnv( wxT( "XDG_CONFIG_HOME" ), &envstr ) || envstr.IsEmpty() )
{
// XDG_CONFIG_HOME is not set, so use the fallback
cfgpath.AppendDir( wxT( ".config" ) );
}
else
{
// Override the assignment above with XDG_CONFIG_HOME
cfgpath.AssignDir( envstr );
}
#endif
cfgpath.AppendDir( wxT( "kicad" ) );
if( !cfgpath.DirExists() )
{
cfgpath.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL );
}
return cfgpath.GetPath();
}
示例7: defined
bool nsEnvVars::EnvvarVetoUI(const wxString& key, wxCheckListBox* lstEnvVars, int sel)
{
#if defined(TRACE_ENVVARS)
Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarVetoUI")));
#endif
if (wxGetEnv(key, NULL))
{
wxString recursion;
if (platform::windows) recursion = _T("PATH=%PATH%;C:\\NewPath");
else recursion = _T("PATH=$PATH:/new_path");
wxString warn_exist;
warn_exist.Printf(_("Warning: Environment variable '%s' is already set.\n"
"Continue with updating it's value?\n"
"(Recursions like '%s' will be considered.)"),
key.wx_str(), recursion.wx_str());
if (cbMessageBox(warn_exist, _("Confirmation"),
wxYES_NO | wxICON_QUESTION) == wxID_NO)
{
if (lstEnvVars && (sel>=0))
lstEnvVars->Check(sel, false); // Unset to visualise it's NOT set
return true; // User has vetoed the operation
}
}// if
return false;
}// EnvvarVetoUI
示例8: wxExpandEnvVars
const wxString S3D_MASTER::GetShape3DFullFilename()
{
wxString shapeName;
// Expand any environment variables embedded in footprint's m_Shape3DName field.
// To ensure compatibility with most of footprint's m_Shape3DName field,
// if the m_Shape3DName is not an absolute path the default path
// given by the environment variable KISYS3DMOD will be used
if( m_Shape3DName.StartsWith( wxT("${") ) )
shapeName = wxExpandEnvVars( m_Shape3DName );
else
shapeName = m_Shape3DName;
wxFileName fn( shapeName );
if( fn.IsAbsolute() || shapeName.StartsWith( wxT(".") ) )
return shapeName;
wxString default_path;
wxGetEnv( KISYS3DMOD, &default_path );
if( default_path.IsEmpty() )
return shapeName;
if( !default_path.EndsWith( wxT("/") ) && !default_path.EndsWith( wxT("\\") ) )
default_path += wxT("/");
default_path += shapeName;
return default_path;
}
示例9: 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
}
示例10: result
wxString EnvironmentConfig::DoExpandVariables(const wxString& in)
{
wxString result(in);
wxString varName, text;
DollarEscaper de(result);
while ( MacroManager::Instance()->FindVariable(result, varName, text) ) {
wxString replacement;
if(varName == wxT("MAKE")) {
//ignore this variable, since it is probably was passed here
//by the makefile generator
replacement = wxT("___MAKE___");
} else {
//search for an environment with this name
wxGetEnv(varName, &replacement);
}
result.Replace(text, replacement);
}
//restore the ___MAKE___ back to $(MAKE)
result.Replace(wxT("___MAKE___"), wxT("$(MAKE)"));
return result;
}
示例11: DisplayInfoMessage
const wxString& PGM_BASE::GetEditorName( bool aCanShowFileChooser )
{
wxString editorname = m_editor_name;
if( !editorname )
{
if( !wxGetEnv( wxT( "EDITOR" ), &editorname ) )
{
// If there is no EDITOR variable set, try the desktop default
#ifdef __WXMAC__
editorname = "/usr/bin/open";
#elif __WXX11__
editorname = "/usr/bin/xdg-open";
#endif
}
}
// If we still don't have an editor name show a dialog asking the user to select one
if( !editorname && aCanShowFileChooser )
{
DisplayInfoMessage( NULL,
_( "No default editor found, you must choose it" ) );
editorname = AskUserForPreferredEditor();
}
// If we finally have a new editor name request it to be copied to m_editor_name and
// saved to the preferences file.
if( !editorname.IsEmpty() )
SetEditorName( editorname );
// m_editor_name already has the same value that editorname, or empty if no editor was
// found/chosen.
return m_editor_name;
}
示例12: xdg_user_dir_lookup_with_fallback
wxString Path::GetDesktopDir()
{
char *desktopDir = xdg_user_dir_lookup_with_fallback("DESKTOP", NULL);
if (desktopDir != NULL)
{
wxString desktop = wxString(desktopDir);
std::cout << "Desktop/XDG: " << desktop << std::endl;
free (desktopDir);
return desktop;
}
free (desktopDir);
wxString homeDir;
if (wxGetEnv("HOME", &homeDir))
{
wxString desktopDir = Path::Combine(homeDir, "Desktop");
if(!wxDirExists(desktopDir))
{
std::cout << "Using home as a fallback: " << homeDir << std::endl;
return homeDir;
}
else
{
std::cout << "Desktop/Guess: " << desktopDir << std::endl;
return desktopDir;
}
}
else
{
std::cout << "Desktop: not found" << std::endl;
return wxEmptyString;
}
}
示例13: PathExpand
bool PathExpand(wxString& cmd)
{
#ifndef __WXMSW__
if (cmd[0] == '/')
return true;
#else
if (cmd[0] == '\\')
// UNC or root of current working dir, whatever that is
return true;
if (cmd.Len() > 2 && cmd[1] == ':')
// Absolute path
return true;
#endif
// Need to search for program in $PATH
wxString path;
if (!wxGetEnv(_T("PATH"), &path))
return false;
wxString full_cmd;
bool found = wxFindFileInPath(&full_cmd, path, cmd);
#ifdef __WXMSW__
if (!found && cmd.Right(4).Lower() != _T(".exe"))
{
cmd += _T(".exe");
found = wxFindFileInPath(&full_cmd, path, cmd);
}
#endif
if (!found)
return false;
cmd = full_cmd;
return true;
}
示例14: CPPUNIT_ASSERT
void EnvTestCase::Path()
{
wxString contents;
CPPUNIT_ASSERT(wxGetEnv(wxT("PATH"), &contents));
CPPUNIT_ASSERT(!contents.empty());
}
示例15: readlink
wxString wxStandardPaths::GetExecutablePath() const
{
#ifdef __LINUX__
wxString exeStr;
char buf[4096];
int result = readlink("/proc/self/exe", buf, WXSIZEOF(buf) - sizeof(char));
if ( result != -1 )
{
buf[result] = '\0'; // readlink() doesn't NUL-terminate the buffer
// if the /proc/self/exe symlink has been dropped by the kernel for
// some reason, then readlink() could also return success but
// "(deleted)" as link destination...
if ( strcmp(buf, "(deleted)") != 0 )
exeStr = wxString(buf, wxConvLibc);
}
if ( exeStr.empty() )
{
// UPX-specific hack: when using UPX on linux, the kernel will drop the
// /proc/self/exe link; in this case we try to look for a special
// environment variable called " " which is created by UPX to save
// /proc/self/exe contents. See
// http://sf.net/tracker/?func=detail&atid=309863&aid=1565357&group_id=9863
// for more information about this issue.
wxGetEnv(wxT(" "), &exeStr);
}
if ( !exeStr.empty() )
return exeStr;
#endif // __LINUX__
return wxStandardPathsBase::GetExecutablePath();
}