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 }
wxString WinPathToCygwin(const wxFileName& path) { // static wxASSERT(path.IsOk() && path.IsAbsolute()); // Drive wxString unixPath = wxT("/cygdrive/"); unixPath += path.GetVolume().Lower(); // Dirs const wxArrayString& dirs = path.GetDirs(); for (unsigned int i = 0; i < dirs.GetCount(); ++i) { unixPath += wxT('/') + dirs[i]; } // Filename if (path.HasName()) { unixPath += wxT('/') + path.GetFullName(); } return unixPath; }
void DIALOG_BUILD_BOM::Create_BOM_Lists( int aTypeFile, bool aIncludeSubComponents, char aExportSeparatorSymbol, bool aRunBrowser ) { wxString wildcard; static wxFileName fn; wxFileName current = g_RootSheet->GetScreen()->GetFileName(); s_ExportSeparatorSymbol = aExportSeparatorSymbol; if( !fn.HasName() || fn.GetName()==NAMELESS_PROJECT ) { fn.SetName( current.GetName() ); } // else use a previous run's name, because fn was set before and user // is probably just iteratively refining the BOM. if( fn.GetPath().IsEmpty() ) { fn.SetPath( current.GetPath() ); } // else use a previous run's path, because fn was set before and user // is probably just iteratively refining the BOM. wxString bomDesc = _( "Bill of Materials" ); // translate once, use twice. if( aTypeFile == 0 ) { fn.SetExt( wxT( "lst" ) ); wildcard = bomDesc + wxT( " (*.lst)|*.lst" ); } else { fn.SetExt( wxT( "csv" ) ); wildcard = bomDesc + wxT( " (*.csv)|*.csv" ); } wxFileDialog dlg( this, bomDesc, fn.GetPath(), fn.GetFullName(), wildcard, wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) return; fn = dlg.GetPath(); // remember path+filename+ext for subsequent runs. m_listFileName = dlg.GetPath(); // Close dialog, then show the list (if so requested) switch( aTypeFile ) { case 0: // list CreatePartsAndLabelsFullList( aIncludeSubComponents ); break; case 1: // spreadsheet, Single Part per line CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, false ); break; case 2: // spreadsheet, group Part with same fields per line CreateSpreadSheetPartsFullList( aIncludeSubComponents, s_Add_Location, true ); break; case 3: // spreadsheet, one value per line and no sub-component CreateSpreadSheetPartsShortList(); break; } EndModal( 1 ); if( aRunBrowser ) { wxString editorname = wxGetApp().GetEditorName(); wxString filename = m_listFileName; AddDelimiterString( filename ); ExecuteFile( this, editorname, filename ); } }