本文整理汇总了C++中wxGetCwd函数的典型用法代码示例。如果您正苦于以下问题:C++ wxGetCwd函数的具体用法?C++ wxGetCwd怎么用?C++ wxGetCwd使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxGetCwd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsSameAs
/** Returns true if the two paths are equal. */
bool IsSameAs(const wxString& a, const wxString& b)
{
// Cache the current directory
const wxString cwd = wxGetCwd();
// We normalize everything, except env. variables, which
// can cause problems when the string is not encodable
// using wxConvLibc which wxWidgets uses for the purpose.
const int flags = (wxPATH_NORM_ALL | wxPATH_NORM_CASE) & ~wxPATH_NORM_ENV_VARS;
// Let wxFileName handle the tricky stuff involved in actually
// comparing two paths ... Currently, a path ending with a path-
// seperator will be unequal to the same path without a path-
// seperator, which is probably for the best, but can could
// lead to some unexpected behavior.
wxFileName fn1(a);
wxFileName fn2(b);
fn1.Normalize(flags, cwd);
fn2.Normalize(flags, cwd);
return (fn1.GetFullPath() == fn2.GetFullPath());
}
示例2: fopen
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);
}
示例3: wxExOpenFiles
void wxExOpenFiles(
wxExFrame* frame,
const wxArrayString& files,
long file_flags,
int dir_flags)
{
// std::vector gives compile error.
for (
#ifdef wxExUSE_CPP0X
auto it = files.begin();
#else
wxArrayString::const_iterator it = files.begin();
#endif
it != files.end();
it++)
{
wxString file = *it; // cannot be const because of file = later on
if (file.Contains("*") || file.Contains("?"))
{
wxExDirOpenFile dir(frame, wxGetCwd(), file, file_flags, dir_flags);
dir.FindFiles();
}
else
{
int line = 0;
if (!wxFileName(file).FileExists() && file.Contains(":"))
{
line = atoi(file.AfterFirst(':').c_str());
file = file.BeforeFirst(':');
}
frame->OpenFile(file, line, wxEmptyString, file_flags);
}
}
}
示例4: Unpack
int Unpack(wxFile& pkg_f, std::string src, std::string dst)
{
PKGHeader* m_header = (PKGHeader*) malloc (sizeof(PKGHeader));
wxFile dec_pkg_f;
std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + src + ".dec";
dec_pkg_f.Create(decryptedFile, true);
if (Decrypt(pkg_f, dec_pkg_f, m_header) < 0)
return -1;
dec_pkg_f.Close();
wxFile n_dec_pkg_f(decryptedFile, wxFile::read);
std::vector<PKGEntry> m_entries;
m_entries.resize(m_header->file_count);
PKGEntry *m_entries_ptr = &m_entries[0];
if (!LoadEntries(n_dec_pkg_f, m_header, m_entries_ptr))
return -1;
wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", m_entries.size(), 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL);
for (const PKGEntry& entry : m_entries)
{
UnpackEntry(n_dec_pkg_f, entry, dst + src + "/");
pdlg.Update(pdlg.GetValue() + 1);
}
pdlg.Update(m_entries.size());
n_dec_pkg_f.Close();
wxRemoveFile(decryptedFile);
return 0;
}
示例5: S
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"));
}
}
示例6: wxGetCwd
void PGM_BASE::saveCommonSettings()
{
// m_common_settings is not initialized until fairly late in the
// process startup: initPgm(), so test before using:
if( m_common_settings )
{
wxString cur_dir = wxGetCwd();
m_common_settings->Write( workingDirKey, cur_dir );
m_common_settings->Write( showEnvVarWarningDialog, m_show_env_var_dialog );
// Save the local environment variables.
m_common_settings->SetPath( pathEnvVariables );
for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
{
wxLogTrace( traceEnvVars, wxT( "Saving environment varaiable config entry %s as %s" ),
GetChars( it->first ), GetChars( it->second.GetValue() ) );
m_common_settings->Write( it->first, it->second.GetValue() );
}
m_common_settings->SetPath( wxT( ".." ) );
}
}
示例7: ClearOutputWindow
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);
}
示例8: WXUNUSED
void MyFrame::OnPDF(wxCommandEvent& WXUNUSED(event))
{
wxFileName fileName;
fileName.SetPath(wxGetCwd());
fileName.SetFullName(wxT("default.pdf"));
wxPrintData printData;
printData.SetOrientation(wxPORTRAIT);
printData.SetPaperId(wxPAPER_A4);
printData.SetFilename(fileName.GetFullPath());
{
wxPdfDC dc(printData);
bool ok = dc.StartDoc(_("Printing ..."));
if (ok)
{
dc.StartPage();
Draw(dc);
dc.EndPage();
dc.EndDoc();
}
}
#if defined(__WXMSW__)
ShellExecute(NULL, _T("open"), fileName.GetFullPath(), _T(""), _T(""), 0);
#endif
}
示例9: SaveAbstractLayer
//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;
}
示例10: WXUNUSED
void MainFrame::loadPopulation(wxCommandEvent& WXUNUSED(event))
{
if (experimentRun.isStarted())
{}
else
{
wxFileDialog loadParametersDialog(
this,
_T("Choose a Population File"),
wxGetCwd(),
_T(""),
_T("*.xml;*.gz"),
wxOPEN|wxFILE_MUST_EXIST
);
int retVal = loadParametersDialog.ShowModal();
if (retVal==wxID_OK)
{
cout_ << "Loading population file: " << WXSTRING_TO_STRING(loadParametersDialog.GetPath()) << endl;
populationFileName = WXSTRING_TO_STRING(loadParametersDialog.GetFilename());
experimentRun.setupExperimentInProgress(
WXSTRING_TO_STRING(loadParametersDialog.GetPath()),
WXSTRING_TO_STRING(loadParametersDialog.GetPath())+string(".new")
);
fileMenu->FindItem(wxID_RUNEXPERIMENT_MENUITEM)->Enable(true);
int genCount = experimentRun.getPopulation()->getGenerationCount();
updateNumGenerations(genCount);
setPopulationSize(int(NEAT::Globals::getSingleton()->getParameterValue("PopulationSize")));
return;
}
}
}
示例11: MyDirGuard
MyDirGuard() : _d( wxGetCwd() ) {}
示例12: wxASSERT_MSG
bool wxGenericFileCtrl::Create( wxWindow *parent,
wxWindowID id,
const wxString& defaultDirectory,
const wxString& defaultFileName,
const wxString& wildCard,
long style,
const wxPoint& pos,
const wxSize& size,
const wxString& name )
{
this->m_style = style;
m_inSelected = false;
m_noSelChgEvent = false;
m_check = NULL;
// check that the styles are not contradictory
wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_OPEN ) ),
wxT( "can't specify both wxFC_SAVE and wxFC_OPEN at once" ) );
wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_MULTIPLE ) ),
wxT( "wxFC_MULTIPLE can't be used with wxFC_SAVE" ) );
wxNavigationEnabled<wxControl>::Create( parent, id,
pos, size,
wxTAB_TRAVERSAL,
wxDefaultValidator,
name );
m_dir = defaultDirectory;
m_ignoreChanges = true;
if ( ( m_dir.empty() ) || ( m_dir == wxT( "." ) ) )
{
m_dir = wxGetCwd();
if ( m_dir.empty() )
m_dir = wxFILE_SEP_PATH;
}
const size_t len = m_dir.length();
if ( ( len > 1 ) && ( wxEndsWithPathSeparator( m_dir ) ) )
m_dir.Remove( len - 1, 1 );
m_filterExtension = wxEmptyString;
// layout
const bool is_pda = ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA );
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *staticsizer = new wxBoxSizer( wxHORIZONTAL );
if ( is_pda )
staticsizer->Add( new wxStaticText( this, wxID_ANY, _( "Current directory:" ) ),
wxSizerFlags().DoubleBorder(wxRIGHT) );
m_static = new wxStaticText( this, wxID_ANY, m_dir );
staticsizer->Add( m_static, 1 );
mainsizer->Add( staticsizer, wxSizerFlags().Expand().Border());
long style2 = wxLC_LIST;
if ( !( m_style & wxFC_MULTIPLE ) )
style2 |= wxLC_SINGLE_SEL;
#ifdef __WXWINCE__
style2 |= wxSIMPLE_BORDER;
#else
style2 |= wxSUNKEN_BORDER;
#endif
m_list = new wxFileListCtrl( this, ID_FILELIST_CTRL,
wxEmptyString, false,
wxDefaultPosition, wxSize( 400, 140 ),
style2 );
m_text = new wxTextCtrl( this, ID_TEXT, wxEmptyString,
wxDefaultPosition, wxDefaultSize,
wxTE_PROCESS_ENTER );
m_choice = new wxChoice( this, ID_CHOICE );
if ( is_pda )
{
// PDAs have a different screen layout
mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().HorzBorder() );
wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL );
textsizer->Add( m_text, wxSizerFlags( 1 ).Centre().Border() );
textsizer->Add( m_choice, wxSizerFlags( 1 ).Centre().Border() );
mainsizer->Add( textsizer, wxSizerFlags().Expand() );
}
else // !is_pda
{
mainsizer->Add( m_list, wxSizerFlags( 1 ).Expand().Border() );
mainsizer->Add( m_text, wxSizerFlags().Expand().Border() );
wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
choicesizer->Add( m_choice, wxSizerFlags( 1 ).Centre() );
if ( !( m_style & wxFC_NOSHOWHIDDEN ) )
{
//.........这里部分代码省略.........
示例13: wxStringTokenize
void EnvVarsTableDlg::OnExport(wxCommandEvent& event)
{
int selection = m_notebook1->GetSelection();
if(selection == wxNOT_FOUND)
return;
#ifdef __WXMSW__
bool isWindows = true;
#else
bool isWindows = false;
#endif
wxString text;
if(selection == 0) {
text = m_textCtrlDefault->GetText();
} else {
EnvVarSetPage* page = dynamic_cast<EnvVarSetPage*>(m_notebook1->GetPage((size_t)selection));
if(page) {
text = page->m_textCtrl->GetText();
}
}
if(text.IsEmpty())
return;
wxArrayString lines = wxStringTokenize(text, wxT("\r\n"), wxTOKEN_STRTOK);
wxString envfile;
if(isWindows) {
envfile << wxT("environment.bat");
} else {
envfile << wxT("environment");
}
wxFileName fn(wxGetCwd(), envfile);
wxFFile fp(fn.GetFullPath(), wxT("w+b"));
if(fp.IsOpened() == false) {
wxMessageBox(wxString::Format(_("Failed to open file: '%s' for write"), fn.GetFullPath().c_str()),
wxT("CodeLite"),
wxOK | wxCENTER | wxICON_WARNING);
return;
}
for(size_t i = 0; i < lines.GetCount(); i++) {
wxString sLine = lines.Item(i).Trim().Trim(false);
if(sLine.IsEmpty())
continue;
static wxRegEx reVarPattern(wxT("\\$\\(( *)([a-zA-Z0-9_]+)( *)\\)"));
if(isWindows) {
while(reVarPattern.Matches(sLine)) {
wxString varName = reVarPattern.GetMatch(sLine, 2);
wxString text = reVarPattern.GetMatch(sLine);
sLine.Replace(text, wxString::Format(wxT("%%%s%%"), varName.c_str()));
}
sLine.Prepend(wxT("set "));
sLine.Append(wxT("\r\n"));
} else {
while(reVarPattern.Matches(sLine)) {
wxString varName = reVarPattern.GetMatch(sLine, 2);
wxString text = reVarPattern.GetMatch(sLine);
sLine.Replace(text, wxString::Format(wxT("$%s"), varName.c_str()));
}
sLine.Prepend(wxT("export "));
sLine.Append(wxT("\n"));
}
fp.Write(sLine);
}
wxMessageBox(wxString::Format(_("Environment exported to: '%s' successfully"), fn.GetFullPath().c_str()),
wxT("CodeLite"));
}
示例14: wxGetCwd
// Loads bitmaps
bool wxEmulatorInfo::Load(const wxString& appDir)
{
// Try to find absolute path
wxString absoluteConfigPath = m_emulatorFilename;
if ( !::wxIsAbsolutePath(absoluteConfigPath) )
{
wxString currDir = wxGetCwd();
absoluteConfigPath = currDir + wxString(wxFILE_SEP_PATH) + m_emulatorFilename;
if ( !wxFile::Exists(absoluteConfigPath) )
{
absoluteConfigPath = appDir + wxString(wxFILE_SEP_PATH)
+ m_emulatorFilename;
}
}
if ( !wxFile::Exists(absoluteConfigPath) )
{
wxString str;
str.Printf( wxT("Could not find config file %s"),
absoluteConfigPath.c_str() );
wxMessageBox(str);
return false;
}
wxString rootPath = wxPathOnly(absoluteConfigPath);
{
wxFileConfig config(wxT("wxEmulator"), wxT("wxWidgets"),
absoluteConfigPath, wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
config.Read(wxT("/General/title"), & m_emulatorTitle);
config.Read(wxT("/General/description"), & m_emulatorDescription);
config.Read(wxT("/General/backgroundBitmap"), & m_emulatorBackgroundBitmapName);
wxString colString;
if (config.Read(wxT("/General/backgroundColour"), & colString) ||
config.Read(wxT("/General/backgroundColor"), & colString)
)
{
m_emulatorBackgroundColour = wxHexStringToColour(colString);
}
int x = 0, y = 0, w = 0, h = 0, dw = 0, dh = 0;
config.Read(wxT("/General/screenX"), & x);
config.Read(wxT("/General/screenY"), & y);
config.Read(wxT("/General/screenWidth"), & w);
config.Read(wxT("/General/screenHeight"), & h);
if (config.Read(wxT("/General/deviceWidth"), & dw) && config.Read(wxT("/General/deviceHeight"), & dh))
{
m_emulatorDeviceSize = wxSize(dw, dh);
}
m_emulatorScreenPosition = wxPoint(x, y);
m_emulatorScreenSize = wxSize(w, h);
}
if (!m_emulatorBackgroundBitmapName.empty())
{
wxString absoluteBackgroundBitmapName = rootPath + wxString(wxFILE_SEP_PATH) + m_emulatorBackgroundBitmapName;
if ( !wxFile::Exists(absoluteBackgroundBitmapName) )
{
wxString str;
str.Printf( wxT("Could not find bitmap %s"),
absoluteBackgroundBitmapName.c_str() );
wxMessageBox(str);
return false;
}
wxBitmapType type = wxDetermineImageType(m_emulatorBackgroundBitmapName);
if (type == wxBITMAP_TYPE_INVALID)
return false;
if (!m_emulatorBackgroundBitmap.LoadFile(m_emulatorBackgroundBitmapName, type))
{
wxString str;
str.Printf( wxT("Could not load bitmap file %s"),
m_emulatorBackgroundBitmapName.c_str() );
wxMessageBox(str);
return false;
}
m_emulatorDeviceSize = wxSize(m_emulatorBackgroundBitmap.GetWidth(),
m_emulatorBackgroundBitmap.GetHeight());
}
return true;
}
示例15: wxInitAllImageHandlers
// 'Main program' equivalent: the program execution "starts" here
bool wxEmulatorApp::OnInit()
{
#if wxUSE_LOG
wxLog::DisableTimestamp();
#endif // wxUSE_LOG
wxInitAllImageHandlers();
wxString currentDir = wxGetCwd();
// Use argv to get current app directory
m_appDir = wxFindAppPath(argv[0], currentDir, wxT("WXEMUDIR"));
// If the development version, go up a directory.
#ifdef __WXMSW__
if ((m_appDir.Right(5).CmpNoCase(wxT("DEBUG")) == 0) ||
(m_appDir.Right(11).CmpNoCase(wxT("DEBUGSTABLE")) == 0) ||
(m_appDir.Right(7).CmpNoCase(wxT("RELEASE")) == 0) ||
(m_appDir.Right(13).CmpNoCase(wxT("RELEASESTABLE")) == 0)
)
m_appDir = wxPathOnly(m_appDir);
#endif
// Parse the command-line parameters and options
wxCmdLineParser parser(sg_cmdLineDesc, argc, argv);
int res;
{
wxLogNull log;
res = parser.Parse();
}
if (res == -1 || res > 0 || parser.Found(wxT("h")))
{
#ifdef __X__
wxLog::SetActiveTarget(new wxLogStderr);
#endif
parser.Usage();
return false;
}
if (parser.Found(wxT("v")))
{
#ifdef __X__
wxLog::SetActiveTarget(new wxLogStderr);
#endif
wxString msg;
msg.Printf(wxT("wxWidgets PDA Emulator (c) Julian Smart, 2002 Version %.2f, %s"), wxEMULATOR_VERSION, __DATE__);
wxLogMessage(msg);
return false;
}
if (parser.Found(wxT("u"), & m_displayNumber))
{
// Should only be number, so strip out anything before
// and including a : character
if (m_displayNumber.Find(wxT(':')) != -1)
{
m_displayNumber = m_displayNumber.AfterFirst(wxT(':'));
}
}
if (parser.GetParamCount() == 0)
{
m_emulatorInfo.m_emulatorFilename = wxT("default.wxe");
}
else if (parser.GetParamCount() > 0)
{
m_emulatorInfo.m_emulatorFilename = parser.GetParam(0);
}
// Load the emulation info
if (!LoadEmulator(m_appDir))
{
//wxMessageBox(wxT("Sorry, could not load this emulator. Please check bitmaps are valid."));
return false;
}
// create the main application window
wxEmulatorFrame *frame = new wxEmulatorFrame(wxT("wxEmulator"),
wxPoint(50, 50), wxSize(450, 340));
#if wxUSE_STATUSBAR
frame->SetStatusText(m_emulatorInfo.m_emulatorTitle, 0);
wxString sizeStr;
sizeStr.Printf(wxT("Screen: %dx%d"), (int) m_emulatorInfo.m_emulatorScreenSize.x,
(int) m_emulatorInfo.m_emulatorScreenSize.y);
frame->SetStatusText(sizeStr, 1);
#endif // wxUSE_STATUSBAR
m_containerWindow = new wxEmulatorContainer(frame, wxID_ANY);
frame->SetClientSize(m_emulatorInfo.m_emulatorDeviceSize.x,
m_emulatorInfo.m_emulatorDeviceSize.y);
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
frame->Show(true);
#ifdef __WXX11__
m_xnestWindow = new wxAdoptedWindow;
wxString cmd;
cmd.Printf(wxT("Xnest :%s -geometry %dx%d"),
//.........这里部分代码省略.........