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; }
// 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; }
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))); }
void Application::checkEnvironment() { wxString envVar; if (wxGetEnv("FR_HOME", &envVar)) config().setHomePath(translatePathMacros(envVar)); if (wxGetEnv("FR_USER_HOME", &envVar)) config().setUserHomePath(translatePathMacros(envVar)); }
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; }
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 ); }
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; }
/* * 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 <*****@*****.**> * 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(); }
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
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; }
/// 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 }
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; }
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; }
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; } }
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; }
bool nsEnvVars::EnvvarDiscard(const wxString &key) { #if defined(TRACE_ENVVARS) Manager::Get()->GetLogManager()->DebugLog(F(_T("EnvvarDiscard"))); #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; if (!wxGetEnv(the_key, NULL)) return false; // envvar was not set - nothing to do. std::map<wxString,wxString>::iterator it = nsEnvVars::EnvVarsStack.find(the_key); if (it!=nsEnvVars::EnvVarsStack.end()) // found an old envvar on the stack return nsEnvVars::EnvvarApply(the_key, it->second); // restore old value if (!wxUnsetEnv(the_key)) { Manager::Get()->GetLogManager()->Log(F( _("Unsetting environment variable '%s' failed."), the_key.wx_str()) ); EV_DBGLOG(_T("EnvVars: Unsetting environment variable '%s' failed."), the_key.wx_str()); return false; } return true; }// EnvvarDiscard
void EnvTestCase::Path() { wxString contents; CPPUNIT_ASSERT(wxGetEnv(wxT("PATH"), &contents)); CPPUNIT_ASSERT(!contents.empty()); }
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(); }
WIZARD_FPLIB_TABLE::WIZARD_FPLIB_TABLE( wxWindow* aParent ) : WIZARD_FPLIB_TABLE_BASE( aParent ), m_welcomeDlg( m_pages[0] ), m_fileSelectDlg( m_pages[1] ), m_githubListDlg( m_pages[2] ), m_reviewDlg( m_pages[3] ), m_targetDlg( m_pages[4] ), m_selectedFilter( 0 ) { m_filePicker->SetFilter( getFilterString() ); // Initialize default download dir wxString default_path; wxGetEnv( FP_LIB_TABLE::GlobalPathEnvVariableName(), &default_path ); setDownloadDir( default_path ); m_filePicker->SetPath( default_path ); // Restore the Github url wxString githubUrl; wxConfigBase* cfg = Pgm().CommonSettings(); cfg->Read( KICAD_FPLIBS_URL_KEY, &githubUrl ); cfg->Read( KICAD_FPLIBS_LAST_DOWNLOAD_DIR, &m_lastGithubDownloadDirectory ); if( !m_lastGithubDownloadDirectory.IsEmpty() ) { setDownloadDir( m_lastGithubDownloadDirectory ); m_filePicker->SetPath( m_lastGithubDownloadDirectory ); } else { m_lastGithubDownloadDirectory = default_path; } if( githubUrl.IsEmpty() ) githubUrl = wxT( "https://github.com/KiCad" ); SetGithubURL( githubUrl ); // Give the minimal size to the dialog, which allows displaying any page wxSize minsize; for( unsigned ii = 0; ii < m_pages.size(); ii++ ) { wxSize size = m_pages[ii]->GetSizer()->CalcMin(); minsize.x = std::max( minsize.x, size.x ); minsize.y = std::max( minsize.y, size.y ); } SetMinSize( minsize ); SetPageSize( minsize ); GetSizer()->SetSizeHints( this ); Center(); if( !m_radioAddGithub->GetValue() && !m_radioAddLocal->GetValue() ) m_radioAddLocal->SetValue( true ); setupDialogOrder(); updateGithubControls(); Connect( wxEVT_RADIOBUTTON, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSourceCheck ), NULL, this ); Connect( wxEVT_DIRCTRL_SELECTIONCHANGED, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnSelectFiles ), NULL, this ); Connect( wxEVT_CHECKLISTBOX, wxCommandEventHandler( WIZARD_FPLIB_TABLE::OnCheckGithubList ), NULL, this ); }
void wxWindowMGL::HandlePaint(MGLDevCtx *dc) { if ( IsFrozen() ) { // Don't paint anything if the window is frozen. m_refreshAfterThaw = true; return; } #if wxDEBUG_LEVEL >= 2 // FIXME_MGL -- debugging stuff, to be removed! static int debugPaintEvents = -1; if ( debugPaintEvents == -1 ) debugPaintEvents = wxGetEnv(wxT("WXMGL_DEBUG_PAINT_EVENTS"), NULL); if ( debugPaintEvents ) { dc->setColorRGB(255,0,255); dc->fillRect(-1000,-1000,2000,2000); wxMilliSleep(50); } #endif // wxDEBUG_LEVEL >= 2 MGLRegion clip; dc->getClipRegion(clip); m_updateRegion = wxRegion(clip); m_paintMGLDC = dc; #if wxUSE_CARET // must hide caret temporarily, otherwise we'd get rendering artifacts wxCaret *caret = GetCaret(); if ( caret ) caret->Hide(); #endif // wxUSE_CARET if ( m_eraseBackground != 0 ) { wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); } m_eraseBackground = -1; wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); #if wxUSE_CARET if ( caret ) caret->Show(); #endif // wxUSE_CARET m_paintMGLDC = NULL; m_updateRegion.Clear(); }
void cxEnv::AddSystemVars(const bool isUnix, const wxString &baseAppPath) { // TM_SUPPORT_PATH wxFileName supportPath = baseAppPath; supportPath.AppendDir(wxT("Support")); const bool supportPathExists = supportPath.DirExists(); if (supportPathExists) { const wxString tmSupportPath = isUnix ? eDocumentPath::WinPathToCygwin(supportPath) : supportPath.GetPath(); this->SetEnv(wxT("TM_SUPPORT_PATH"), tmSupportPath); // TM_BASH_INIT if (isUnix) { wxFileName bashInit = supportPath; bashInit.AppendDir(wxT("lib")); bashInit.SetFullName(wxT("cygwin_bash_init.sh")); if (bashInit.FileExists()) { wxString s_tmBashInit = eDocumentPath::WinPathToCygwin(bashInit); this->SetEnv(wxT("TM_BASH_INIT"), s_tmBashInit); } } } // PATH wxString envPath; if (wxGetEnv(wxT("PATH"), &envPath)) { #ifdef __WXMSW__ // Check if cygwin is on the path if (!eDocumentPath::CygwinPath().empty()) { if (!envPath.Contains(eDocumentPath::CygwinPath())) { const wxString binPath = eDocumentPath::CygwinPath() + wxT("\\bin"); const wxString x11Path = eDocumentPath::CygwinPath() + wxT("\\usr\\X11R6\\bin"); if (!envPath.empty()) { envPath = binPath + wxT(";") + x11Path + wxT(";") + envPath; } } } #endif // __WXMSW__ // Add TM_SUPPORT_PATH/bin to the PATH if (supportPathExists) { wxFileName supportBinPath = supportPath; supportBinPath.AppendDir(wxT("bin")); if (supportBinPath.DirExists()) { envPath = supportBinPath.GetPath() + wxT(";") + envPath; } } this->SetEnv(wxT("PATH"), envPath); } // TM_APPPATH wxString appPath = baseAppPath; if (isUnix) appPath = eDocumentPath::WinPathToCygwin(appPath); this->SetEnv(wxT("TM_APPPATH"), appPath); // TM_FULLNAME this->SetEnv(wxT("TM_FULLNAME"), wxGetUserName()); }
bool DbgGdb::DoLocateGdbExecutable(const wxString& debuggerPath, wxString& dbgExeName) { if (m_gdbProcess) { //dont allow second instance of the debugger return false; } wxString cmd; dbgExeName = debuggerPath; if (dbgExeName.IsEmpty()) { dbgExeName = wxT("gdb"); } wxString actualPath; if (ExeLocator::Locate(dbgExeName, actualPath) == false) { wxMessageBox(wxString::Format(wxT("Failed to locate gdb! at '%s'"), dbgExeName.c_str()), wxT("EmbeddedLite")); return false; } // set the debugger specific startup commands wxString startupInfo ( m_info.startupCommands ); // We must replace TABS with spaces or else gdb will hang... startupInfo.Replace(wxT("\t"), wxT(" ")); // Write the content into a file wxString codelite_gdbinit_file; #ifdef __WXMSW__ codelite_gdbinit_file << wxFileName::GetTempDir() << wxFileName::GetPathSeparator() << wxT("codelite_gdbinit.txt"); #else wxString home_env; if( !wxGetEnv(wxT("HOME"), &home_env) ) { m_observer->UpdateAddLine(wxString::Format(wxT("Failed to read HOME environment variable"))); } else { codelite_gdbinit_file << home_env << wxT("/") << wxT(".gdbinit"); if( wxFileName::FileExists(codelite_gdbinit_file) && !wxFileName::FileExists(codelite_gdbinit_file + wxT(".backup"))) { wxCopyFile(codelite_gdbinit_file, codelite_gdbinit_file + wxT(".backup") ); m_observer->UpdateAddLine(wxString::Format(wxT(".gdbinit file was backup to %s"), wxString(codelite_gdbinit_file + wxT(".backup")).c_str())); } } #endif wxFFile file; if (!file.Open(codelite_gdbinit_file, wxT("w+b"))) { m_observer->UpdateAddLine(wxString::Format(wxT("Failed to generate gdbinit file at %s"), codelite_gdbinit_file.c_str())); } else { m_observer->UpdateAddLine(wxString::Format(wxT("Using gdbinit file: %s"), codelite_gdbinit_file.c_str())); file.Write(startupInfo); file.Close(); #ifdef __WXMSW__ dbgExeName << wxT(" --command=\"") << codelite_gdbinit_file << wxT("\""); #endif } return true; }
//--------------------------------------------------------- bool SG_Get_Environment(const CSG_String &Variable, CSG_String *Value) { if( Value == NULL) { return( wxGetEnv(Variable.w_str(), NULL) ); } wxString s; if( wxGetEnv(Variable.w_str(), &s) ) { *Value = s.wc_str(); return( true ); } return( false ); }
void COptions::InitSettingsDir() { wxFileName fn; wxString dir(GetOption(OPTION_DEFAULT_SETTINGSDIR)); if (!dir.empty()) { wxStringTokenizer tokenizer(dir, _T("/\\"), wxTOKEN_RET_EMPTY_ALL); dir = _T(""); while (tokenizer.HasMoreTokens()) { wxString token = tokenizer.GetNextToken(); if (token[0] == '$') { if (token[1] == '$') token = token.Mid(1); else { wxString value; if (wxGetEnv(token.Mid(1), &value)) token = value; } } dir += token; const wxChar delimiter = tokenizer.GetLastDelimiter(); if (delimiter) dir += delimiter; } fn = wxFileName(dir, _T("")); fn.Normalize(wxPATH_NORM_ALL, wxGetApp().GetDefaultsDir()); } else { #ifdef __WXMSW__ wxChar buffer[MAX_PATH * 2 + 1]; if (SUCCEEDED(SHGetFolderPath(0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT, buffer))) { fn = wxFileName(buffer, _T("")); fn.AppendDir(_T("FileZilla")); } else { // Fall back to directory where the executable is if (GetModuleFileName(0, buffer, MAX_PATH * 2)) fn = buffer; } #else fn = wxFileName(wxGetHomeDir(), _T("")); fn.AppendDir(_T(".filezilla")); #endif } if (!fn.DirExists()) wxMkdir(fn.GetPath(), 0700); SetOption(OPTION_DEFAULT_SETTINGSDIR, fn.GetPath()); }
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 }
wxString Path::GetDesktopDir() { wxString homeDir; if (wxGetEnv("HOME", &homeDir)) return Path::Combine(homeDir, "Desktop"); else return wxEmptyString; }
wxString S3D_CACHE::Get3DConfigDir( bool createDefault ) { if( !m_ConfigDir.empty() || !createDefault ) return m_ConfigDir; // note: duplicated from common/common.cpp GetKicadConfigPath() to avoid // code coupling; ideally the instantiating code should call // Set3DConfigDir() to set the directory rather than relying on this // directory remaining the same in future KiCad releases. 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" ) ); cfgpath.AppendDir( wxT( "3d" ) ); if( !cfgpath.DirExists() ) { cfgpath.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); } if( !cfgpath.DirExists() ) { std::ostringstream ostr; wxString errmsg = "failed to create 3D configuration directory"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * " << errmsg.ToUTF8(); wxLogTrace( MASK_3D_CACHE, "%s\n", ostr.str().c_str() ); return wxT( "" ); } if( Set3DConfigDir( cfgpath.GetPath() ) ) return m_ConfigDir; return wxEmptyString; }
void GraphicsContextDrawingTestCase::RunPluginsDrawingCase ( const DrawingTestCase & testCase) { if (!m_drawingPluginsLoaded) { m_drawingPluginsLoaded = true; wxString pluginsListStr; if (!wxGetEnv ("WX_TEST_SUITE_GC_DRAWING_PLUGINS", &pluginsListStr)) return; // no plugins wxArrayString pluginsNameArray = wxSplit (pluginsListStr, ',', '\0'); m_drawingPlugins.resize (pluginsNameArray.size()); for (size_t idx=0; idx<pluginsNameArray.size(); ++idx) { PluginInfo &pluginBeingLoaded = m_drawingPlugins[idx]; pluginBeingLoaded.library = new wxDynamicLibrary; if (!pluginBeingLoaded.library->Load (pluginsNameArray[idx])) { wxLogFatalError("could not load drawing plugin %s", pluginsNameArray[idx]); return; } wxDYNLIB_FUNCTION(CreateDrawingTestLifeCycleFunction, CreateDrawingTestLifeCycle, *pluginBeingLoaded.library); wxDYNLIB_FUNCTION(DestroyDrawingTestLifeCycleFunction, DestroyDrawingTestLifeCycle, *pluginBeingLoaded.library); if (!pfnCreateDrawingTestLifeCycle || !pfnDestroyDrawingTestLifeCycle) { wxLogFatalError("could not find function" " CreateDrawingTestLifeCycle or " "DestroyDrawingTestLifeCycle in %s", pluginsNameArray[idx]); return; } pluginBeingLoaded.destroy = pfnDestroyDrawingTestLifeCycle; pluginBeingLoaded.gcFactory = (*pfnCreateDrawingTestLifeCycle)(); if (!pluginBeingLoaded.gcFactory) { wxLogFatalError("failed to create life-cycle object in %s", pluginsNameArray[idx]); return; } } } // now execute the test case for each plugin for (size_t idxp=0; idxp<m_drawingPlugins.size(); ++idxp) { RunIndividualDrawingCase (*m_drawingPlugins[idxp].gcFactory, testCase); } }
bool GraphicsContextDrawingTestCase::GetBuildReference() const { if (!ms_buildReferenceDetermined) { wxString value; if (wxGetEnv("WX_TEST_SUITE_BUILD_REFERENCE", &value)) ms_buildReference = value == "1"; } return ms_buildReference; }
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)); }