//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc) bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath ) { dest.IsFormatted = false; dest.IsPresent = false; const wxString fullpath( filename.GetFullPath() ); if( !filename.FileExists() ) return false; DevCon.WriteLn( fullpath ); wxFFile mcdFile( fullpath ); if( !mcdFile.IsOpened() ) return false; // wx should log the error for us. if( mcdFile.Length() < (1024*528) ) { Console.Warning( "... MemoryCard appears to be truncated. Ignoring." ); return false; } dest.IsPresent = true; dest.Filename = filename; if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() ) dest.Filename = filename.GetFullName(); dest.SizeInMB = (uint)(mcdFile.Length() / (1024 * 528 * 2)); dest.IsFormatted = IsMcdFormatted( mcdFile ); filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); return true; }
/** DoLoadFile * * Handles loading an assembly file into the simulator */ void ComplxFrame::DoLoadFile(const wxFileName& filename) { //CleanUp(); lc3_state dummy_state; lc3_init(dummy_state); // Save the symbols std::map<std::string, unsigned short> symbol_table = state.symbols; std::map<unsigned short, std::string> rev_symbol_table = state.rev_symbols; state.symbols.clear(); state.rev_symbols.clear(); lc3_remove_plugins(state); try { lc3_assemble(dummy_state, filename.GetFullPath().ToStdString(), false); lc3_assemble(state, filename.GetFullPath().ToStdString()); } catch (LC3AssembleException e) { wxMessageBox(wxString::Format("BAD STUDENT! %s", e.what()), _("Loading ") + filename.GetFullName() + _(" Failed")); goto merge; } catch (std::vector<LC3AssembleException> e) { std::stringstream oss; for (unsigned int i = 0; i < e.size(); i++) oss << e[i].what() << std::endl; wxMessageBox(wxString::Format("BAD STUDENT! %s", oss.str()), _("Loading ") + filename.GetFullName() + _(" Failed")); goto merge; } //if (DoAssemble(filename)) return; currentFile = filename; SetTitle(wxString::Format("Complx - %s", filename.GetFullPath())); merge: std::map<std::string, unsigned short>::const_iterator i; std::map<unsigned short, std::string>::const_iterator j; for (i = symbol_table.begin(); i != symbol_table.end(); ++i) { state.symbols[i->first] = i->second; } for (j = rev_symbol_table.begin(); j != rev_symbol_table.end(); ++j) { state.rev_symbols[j->first] = j->second; } //DoLoad(filename); UpdateStatus(); UpdateRegisters(); UpdateMemory(); }
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc) bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath ) { dest.IsFormatted = false; dest.IsPresent = false; dest.IsPSX = false; dest.Type = MemoryCardType::MemoryCard_None; const wxString fullpath( filename.GetFullPath() ); //DevCon.WriteLn( fullpath ); if ( filename.FileExists() ) { // might be a memory card file wxFFile mcdFile( fullpath ); if ( !mcdFile.IsOpened() ) { return false; } // wx should log the error for us. wxFileOffset length = mcdFile.Length(); if( length < (1024*528) && length != 0x20000 ) { Console.Warning( "... MemoryCard appears to be truncated. Ignoring." ); return false; } dest.SizeInMB = (uint)( length / ( 1024 * 528 * 2 ) ); if ( length == 0x20000 ) { dest.IsPSX = true; // PSX memcard; dest.SizeInMB = 1; // MegaBIT } dest.Type = MemoryCardType::MemoryCard_File; dest.IsFormatted = IsMcdFormatted( mcdFile ); filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); } else if ( filename.DirExists() ) { // might be a memory card folder wxFileName superBlockFileName( fullpath, L"_pcsx2_superblock" ); if ( !superBlockFileName.FileExists() ) { return false; } wxFFile mcdFile( superBlockFileName.GetFullPath() ); if ( !mcdFile.IsOpened() ) { return false; } dest.SizeInMB = 0; dest.Type = MemoryCardType::MemoryCard_Folder; dest.IsFormatted = IsMcdFormatted( mcdFile ); superBlockFileName.GetTimes( NULL, &dest.DateModified, &dest.DateCreated ); } else { // is neither return false; } dest.IsPresent = true; dest.Filename = filename; if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() ) dest.Filename = filename.GetFullName(); return true; }
bool FileUtils::IsHidden(const wxFileName& filename) { #ifdef __WXMSW__ DWORD dwAttrs = GetFileAttributes(filename.GetFullPath().c_str()); if(dwAttrs == INVALID_FILE_ATTRIBUTES) return false; return (dwAttrs & FILE_ATTRIBUTE_HIDDEN) || (filename.GetFullName().StartsWith(".")); #else // is it enough to test for file name? return filename.GetFullName().StartsWith("."); #endif }
// originally an ExportMultiple method. Append suffix if newName appears in otherNames. void FileNames::MakeNameUnique(wxArrayString &otherNames, wxFileName &newName) { if (otherNames.Index(newName.GetFullName(), false) >= 0) { int i=2; wxString orig = newName.GetName(); do { newName.SetName(wxString::Format(wxT("%s-%d"), orig.c_str(), i)); i++; } while (otherNames.Index(newName.GetFullName(), false) >= 0); } otherNames.Add(newName.GetFullName()); }
IFSTREAM_LINE_READER::IFSTREAM_LINE_READER( const wxFileName& aFileName ) throw( IO_ERROR ) : m_fStream( aFileName.GetFullName().ToUTF8() ) { if( !m_fStream.is_open() ) { wxString msg = wxString::Format( _( "Unable to open filename '%s' for reading" ), aFileName.GetFullPath().GetData() ); THROW_IO_ERROR( msg ); } setStream( m_fStream ); source = aFileName.GetFullName(); }
// Checks whether 'suffix' could be a suffix of 'path' and therefore represents // the same path. This is used to check whether a relative path could represent // the same path as absolute path. For instance, for // suffix = sdk/globals.cpp // path = /home/user/codeblocks/trunk/src/sdk/globals.cpp // it returns true. The function expects that 'path' is normalized and compares // 'path' with 'suffix' starting from the end of the path. When it reaches .. in // 'suffix' it gives up (there is no way to check relative filename names // exactly) and if the path compared so far is identical, it returns true bool IsSuffixOfPath(wxFileName const & suffix, wxFileName const & path) { if (path.GetFullName() != suffix.GetFullName()) { return false; } wxArrayString suffixDirArray = suffix.GetDirs(); wxArrayString pathDirArray = path.GetDirs(); int j = pathDirArray.GetCount() - 1; for (int i = suffixDirArray.GetCount() - 1; i >= 0; i--) { if (suffixDirArray[i] == _T(".") || suffixDirArray[i] == _T("")) { // skip paths like /./././ and //// continue; } if (j < 0) { // suffix has more directories than path - cannot represent the same path return false; } if (suffixDirArray[i] == _T("..")) { // suffix contains ".." - from now on we cannot precisely determine // whether suffix and path match - we assume that they do return true; } else if (suffixDirArray[i] != pathDirArray[j]) { // the corresponding directories of the two paths differ return false; } j--; } if (suffix.IsAbsolute() && (j >= 0 || suffix.GetVolume() != path.GetVolume())) { return false; } // 'suffix' is a suffix of 'path' return true; }
bool FileUtils::WildMatch(const wxString& mask, const wxFileName& filename) { wxArrayString incMasks; wxArrayString excMasks; SplitMask(mask, incMasks, excMasks); if(incMasks.Index("*") != wxNOT_FOUND) { // If one of the masks is plain "*" - we match everything return true; } wxString lcFilename = filename.GetFullName().Lower(); // Try to the "exclude" masking first for(size_t i = 0; i < excMasks.size(); ++i) { const wxString& pattern = excMasks.Item(i); if((!pattern.Contains("*") && lcFilename == pattern) || (pattern.Contains("*") && ::wxMatchWild(pattern, lcFilename))) { // use exact match return false; } } for(size_t i = 0; i < incMasks.size(); ++i) { const wxString& pattern = incMasks.Item(i); if((!pattern.Contains("*") && lcFilename == pattern) || (pattern.Contains("*") && ::wxMatchWild(pattern, lcFilename))) { // use exact match return true; } } return false; }
void wxExFrameWithHistory::FileHistoryPopupMenu() { wxMenu* menu = new wxMenu(); for (int i = 0; i < m_FileHistory.GetCount(); i++) { const wxFileName file(m_FileHistory.GetHistoryFile(i)); if (file.FileExists()) { wxMenuItem* item = new wxMenuItem( menu, wxID_FILE1 + i, file.GetFullName()); item->SetBitmap(wxTheFileIconsTable->GetSmallImageList()->GetBitmap( wxExGetIconID(file))); menu->Append(item); } } if (menu->GetMenuItemCount() > 0) { menu->AppendSeparator(); menu->Append(ID_CLEAR, wxGetStockLabel(wxID_CLEAR)); PopupMenu(menu); } delete menu; }
bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename, const wxString& wildcard, const wxString& ext, bool isDirectory ) { wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" ); aFilename.SetExt( ext ); #ifndef __WXMAC__ if( isDirectory && doOpen ) { wxDirDialog dlg( this, prompt, Prj().GetProjectPath(), wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; aFilename = dlg.GetPath(); aFilename.SetExt( ext ); } else #endif { wxFileDialog dlg( this, prompt, Prj().GetProjectPath(), aFilename.GetFullName() , wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return false; aFilename = dlg.GetPath(); aFilename.SetExt( ext ); } return true; }
void BundlePane::OnMenuExport(wxCommandEvent& WXUNUSED(event)) { const wxTreeItemId selItem = m_bundleTree->GetSelection(); if (!selItem.IsOk()) return; // Get the item name const BundleItemData* data = (BundleItemData*)m_bundleTree->GetItemData(selItem); wxString name; if (data->IsBundle()) { const wxFileName bundlePath = m_plistHandler.GetBundlePath(data->m_bundleId); name = bundlePath.GetDirs().Last(); } else { const wxFileName bundlePath = m_plistHandler.GetBundleItemPath(data->m_type, data->m_bundleId, data->m_itemId); name = bundlePath.GetFullName(); } // Get destination path from user const wxString msg = data->IsBundle() ? _("Export Bundle as..") : _("Export Bundle Item as"); wxFileDialog dlg(this, msg, wxEmptyString, name, wxFileSelectorDefaultWildcardStr, wxFD_SAVE); if (dlg.ShowModal() != wxID_OK) return; const wxString path = dlg.GetPath(); if (path.empty()) return; // Export the item if (data->IsBundle()) { wxFileName dstPath; dstPath.AssignDir(path); m_plistHandler.ExportBundle(dstPath, data->m_bundleId); } else m_plistHandler.ExportBundleItem(path, data->m_type, data->m_bundleId, data->m_itemId); }
// See IsAdminDirTopLevel const wxString wxExVCS::GetRelativeFile( const wxString& admin_dir, const wxFileName& fn) const { // The .git dir only exists in the root, so check all components. wxFileName root(fn); wxArrayString as; while (root.DirExists() && root.GetDirCount() > 0) { wxFileName path(root); path.AppendDir(admin_dir); if (path.DirExists() && !path.FileExists()) { wxString relative_file; for (int i = as.GetCount() - 1; i >= 0; i--) { relative_file += as[i] + "/"; } return relative_file + fn.GetFullName(); } as.Add(root.GetDirs().Last()); root.RemoveLastDir(); } return wxEmptyString; }
wxString eDocumentPath::WinPathToCygwin(const wxFileName& path) { wxASSERT(path.IsOk() && path.IsAbsolute()); #ifndef __WXMSW__ return path.GetFullPath(); #else wxString fullpath = path.GetFullPath(); // Check if we have a foward-slash unc path; cygwin can handle these directly. if (fullpath.StartsWith(wxT("//"))) { return fullpath; } // Check if we have a backslash unc path; convert to forward slash and pass on. if (fullpath.StartsWith(wxT("\\\\"))) { fullpath.Replace(wxT("\\"), wxT("/")); return fullpath; } // Convert C:\... to /cygdrive/c/... wxString unixPath = eDocumentPath::s_cygdrivePrefix + path.GetVolume().Lower(); // Convert slashs in path segments const wxArrayString& dirs = path.GetDirs(); for (unsigned int i = 0; i < dirs.GetCount(); ++i) { unixPath += wxT('/') + dirs[i]; } // Add the filename, if there is one if (path.HasName()) unixPath += wxT('/') + path.GetFullName(); return unixPath; #endif }
void MainBook::DoOpenImageViewer(const wxFileName& filename) { clImageViewer* imageViewer = new clImageViewer(m_book, filename); size_t pos = m_book->GetPageCount(); m_book->AddPage(imageViewer, filename.GetFullName(), true); m_book->SetPageToolTip(pos, filename.GetFullPath()); }
void Instance::InsertMod(size_t index, const wxFileName &source) { wxFileName dest(Path::Combine(GetInstModsDir().GetFullPath(), source.GetFullName())); if (!source.SameAs(dest)) { wxCopyFile(source.GetFullPath(), dest.GetFullPath()); } dest.MakeRelativeTo(); SetNeedsRebuild(); int oldIndex = Find(modList.begin(), modList.end(), [&dest] (Mod mod) -> bool { return mod.GetFileName().SameAs(dest); }); if (oldIndex != -1) { modList.erase(modList.begin() + oldIndex); } if (index >= modList.size()) modList.push_back(Mod(dest)); else modList.insert(modList.begin() + index, Mod(dest)); SaveModList(); }
void RunTestDialog::OnReport(wxCommandEvent& event) { std::stringstream oss; lc3_write_test_report(oss, suite, currentFile.GetFullName().ToStdString()); TestReportDialog* dialog = new TestReportDialog(this, currentFile.GetFullName(), oss.str()); if (dialog->ShowModal() == wxID_OK) { delete dialog; return; } delete dialog; }
static void bench_wxis_reuse( const wxFileName& aFile, int aReps, BENCH_REPORT& report ) { S fileStream( aFile.GetFullName() ); INPUTSTREAM_LINE_READER istr( &fileStream, aFile.GetFullName() ); for( int i = 0; i < aReps; ++i) { while( istr.ReadLine() ) { report.linesRead++; report.charAcc += (unsigned char) istr.Line()[0]; } fileStream.SeekI( 0 ); } }
static void bench_wxbis( const wxFileName& aFile, int aReps, BENCH_REPORT& report ) { WXIS fileStream( aFile.GetFullName() ); wxBufferedInputStream bufferedStream( fileStream ); for( int i = 0; i < aReps; ++i) { INPUTSTREAM_LINE_READER istr( &bufferedStream, aFile.GetFullName() ); while( istr.ReadLine() ) { report.linesRead++; report.charAcc += (unsigned char) istr.Line()[0]; } fileStream.SeekI( 0 ); } }
/** DoLoadMachine * * Handles loading a machine state */ void ComplxFrame::DoLoadMachine(const wxFileName& filename) { std::ifstream file(filename.GetFullName().c_str(), std::ios::binary); file.read((char*) &state, sizeof(state)); file.close(); UpdateRegisters(); UpdateMemory(); UpdateStatus(); }
//whether or not this filename appears on the ports at the list (takes into account MT enabled/disabled) bool Panels::MemoryCardListPanel_Simple::isFileAssignedAndVisibleOnList(const wxFileName cardFile) const { int i; for( i=0; i<8; i++) if ( IsSlotVisible(i) && cardFile.GetFullName()==m_Cards[i].Filename.GetFullName() ) return true; return false; }
void ArchiveViewer::SetCurrentFilename(wxFileName filename) { m_CurrentFilename = filename; if (filename.IsOk()) SetTitle(m_WindowTitle + _T(" - ") + filename.GetFullName()); else SetTitle(m_WindowTitle); }
//whether or not this filename is assigned to a ports (regardless if MT enabled/disabled) bool Panels::MemoryCardListPanel_Simple::isFileAssignedToInternalSlot(const wxFileName cardFile) const { int i; for( i=0; i<8; i++) if ( cardFile.GetFullName()==m_Cards[i].Filename.GetFullName() ) return true; return false; }
bool HexEditorCtrl::SaveTAGS( wxFileName flnm ){ if( MainTagArray.Count() == 0){ // if( wxFileName::FileName( flnm.GetFullPath() ).FileExists() ) // wxRemoveFile( flnm.GetFullPath() ); if( wxFileName::FileName( flnm.GetFullPath() << wxT(".tags") ).FileExists() ) wxRemoveFile( flnm.GetFullPath() << wxT(".tags") ); return false; } else{ wxXmlDocument doc; wxXmlNode *node_Root = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT("wxHexEditor_XML_TAG"), wxEmptyString, NULL , NULL); #if wxCHECK_VERSION(3, 0, 0) wxXmlAttribute *prop_filename = new wxXmlAttribute( wxT("path"), flnm.GetFullPath(), NULL); #else wxXmlProperty *prop_filename = new wxXmlProperty( wxT("path"), flnm.GetFullPath(), NULL); #endif wxXmlNode *node_File = new wxXmlNode( node_Root, wxXML_ELEMENT_NODE, wxT("filename"), wxEmptyString, prop_filename , NULL); MainTagArray.Sort(TagElementSort); for(signed i = MainTagArray.Count()-1 ; i>=0 ; i-- ){ //Used reverse order for make XML offsets increasing. TagElement *TAG = MainTagArray.Item(i); #if wxCHECK_VERSION(3, 0, 0) wxXmlAttribute *ID = new wxXmlAttribute( wxT("id"), wxString::Format(wxT("%d"),i), NULL ); #else wxXmlProperty *ID = new wxXmlProperty( wxT("id"), wxString::Format(wxT("%d"),i), NULL ); #endif wxXmlNode *node_Tag = new wxXmlNode( node_File, wxXML_ELEMENT_NODE, wxT("TAG"), wxEmptyString, ID , NULL); wxXmlNode *element_NoteColour = new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("note_colour"), wxEmptyString, NULL, NULL); new wxXmlNode( element_NoteColour, wxXML_TEXT_NODE, wxT("note_colour"), TAG->NoteClrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX), NULL, NULL); wxXmlNode *element_FontColour = new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("font_colour"), wxEmptyString, NULL, element_NoteColour); new wxXmlNode( element_FontColour, wxXML_TEXT_NODE, wxT("font_colour"), TAG->FontClrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX), NULL, NULL); wxXmlNode *element_TagText = new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("tag_text"), wxEmptyString, NULL, element_FontColour); new wxXmlNode( element_TagText, wxXML_TEXT_NODE, wxT("tag_text"), TAG->tag, NULL, NULL); wxXmlNode *element_End = new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("end_offset"), wxEmptyString, NULL, element_TagText); new wxXmlNode( element_End, wxXML_TEXT_NODE, wxT("end_offset"), wxString::Format("%" wxLongLongFmtSpec "u",TAG->end ) , NULL, NULL); wxXmlNode *element_Start = new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("start_offset"), wxEmptyString, NULL, element_End); new wxXmlNode( element_Start, wxXML_TEXT_NODE, wxT("start_offset"), wxString::Format("%" wxLongLongFmtSpec "u", TAG->start ), NULL, NULL); } doc.SetFileEncoding( wxT("UTF-8") ); doc.SetRoot( node_Root ); if( !flnm.GetFullName().Lower().EndsWith(wxT(".tags")) ) return doc.Save(flnm.GetFullPath() + wxT(".tags")); return doc.Save(flnm.GetFullPath()); } }
/** OnReloadOver * * Called when the user wants to reload the last file over the current state. */ void ComplxFrame::OnReloadOver(wxCommandEvent& event) { if (Running()) return; if (currentFile.GetFullName().IsEmpty()) { OnLoadOver(event); return; } DoLoadFile(currentFile); }
void Panels::MemoryCardListPanel_Simple::RemoveCardFromSlot(const wxFileName cardFile) { int i; for( i=0; i<8; i++) if ( cardFile.GetFullName()==m_Cards[i].Filename.GetFullName() ) { m_Cards[i].Filename = L""; m_Cards[i].IsPresent = false; m_Cards[i].IsEnabled = false; } }
bool ClangPlugin::IsSourceOf(const wxFileName& candidateFile, const wxFileName& activeFile, bool& isCandidate) { if (candidateFile.GetName().CmpNoCase(activeFile.GetName()) == 0) { isCandidate = (candidateFile.GetName() != activeFile.GetName()); if (FileTypeOf(candidateFile.GetFullName()) == ftSource) { if (candidateFile.GetPath() != activeFile.GetPath()) { wxArrayString fileArray; wxDir::GetAllFiles(candidateFile.GetPath(wxPATH_GET_VOLUME), &fileArray, candidateFile.GetName() + wxT(".*"), wxDIR_FILES | wxDIR_HIDDEN); for (size_t i = 0; i < fileArray.GetCount(); ++i) if (wxFileName(fileArray[i]).GetFullName() == activeFile.GetFullName()) return false; } return candidateFile.FileExists(); } } return false; }
void SymbolTree::BuildTree(const wxFileName &fileName) { // Clear the tree DeleteAllItems(); m_items.clear(); m_globalsNode = wxTreeItemId(); m_prototypesNode = wxTreeItemId(); m_macrosNode = wxTreeItemId(); m_sortItems.clear(); m_fileName = fileName; // Get the current tree m_tree = TagsManagerST::Get()->Load(m_fileName); if ( !m_tree ) { return; } // Add invisible root node wxTreeItemId root; root = AddRoot(fileName.GetFullName(), 15, 15); TreeWalker<wxString, TagEntry> walker(m_tree->GetRoot()); // add three items here: // the globals node, the mcros and the prototype node m_globalsNode = AppendItem(root, wxT("Global Functions and Variables"), 2, 2, new MyTreeItemData(wxT("Global Functions and Variables"), wxEmptyString)); m_prototypesNode = AppendItem(root, wxT("Functions Prototypes"), 2, 2, new MyTreeItemData(wxT("Functions Prototypes"), wxEmptyString)); m_macrosNode = AppendItem(root, wxT("Macros"), 2, 2, new MyTreeItemData(wxT("Macros"), wxEmptyString)); // Iterate over the tree and add items m_sortItems.clear(); Freeze(); for (; !walker.End(); walker++) { // Add the item to the tree TagNode* node = walker.GetNode(); // Skip root node if (node->IsRoot()) continue; // Add the node AddItem(node); } SortTree(m_sortItems); Thaw(); //select the root node by default if (!(GetWindowStyleFlag() & wxTR_HIDE_ROOT)) { //root is visible, select it SelectItem(GetRootItem()); } }
////////////////////////////////////////// // Backup and Restore // void PasswordSafeFrame::OnBackupSafe(wxCommandEvent& /*evt*/) { PWSprefs *prefs = PWSprefs::GetInstance(); const wxFileName currbackup(towxstring(prefs->GetPref(PWSprefs::CurrentBackup))); const wxString title(_("Please Choose a Name for this Backup:")); wxString dir; if (m_core.GetCurFile().empty()) dir = towxstring(PWSdirs::GetSafeDir()); else { wxFileName::SplitPath(towxstring(m_core.GetCurFile()), &dir, NULL, NULL); wxCHECK_RET(!dir.IsEmpty(), _("Could not parse current file path")); } //returns empty string if user cancels wxString wxbf = wxFileSelector(title, dir, currbackup.GetFullName(), wxT("bak"), _("Password Safe Backups (*.bak)|*.bak"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, this); /* The wxFileSelector code says it appends the default extension if user doesn't type one, but it actually doesn't and I don't see the purported code in 2.8.10. And doing it ourselves after the dialog has returned is risky because we might silently overwrite an existing file */ //create a copy to avoid multiple conversions to StringX const StringX backupfile(tostringx(wxbf)); #ifdef NOT_YET if (m_inExit) { // If U3ExitNow called while in CPWFileDialog, // PostQuitMessage makes us return here instead // of exiting the app. Try resignalling PostQuitMessage(0); return PWScore::USER_CANCEL; } #endif if (!backupfile.empty()) { //i.e. if user didn't cancel if (m_core.WriteFile(backupfile, m_core.GetReadFileVersion(), false) == PWScore::CANT_OPEN_FILE) { wxMessageBox( wxbf << wxT("\n\n") << _("Could not open file for writing!"), _("Write Error"), wxOK|wxICON_ERROR, this); } prefs->SetPref(PWSprefs::CurrentBackup, backupfile); } }
static void bench_line_reader( const wxFileName& aFile, int aReps, BENCH_REPORT& report ) { for( int i = 0; i < aReps; ++i) { LR fstr( aFile.GetFullName() ); while( fstr.ReadLine() ) { report.linesRead++; report.charAcc += (unsigned char) fstr.Line()[0]; } } }
/** OnRandomizeAndReload * * Called when the user wants to reload the last file. */ void ComplxFrame::OnRandomizeAndReload(wxCommandEvent& event) { if (Running()) return; if (currentFile.GetFullName().IsEmpty()) { OnLoad(event); return; } OnInit(); lc3_randomize(state); DoLoadFile(currentFile); }