Don't hardcode the file extensions where possible
This commit is contained in:
parent
69e310918e
commit
908de37e7c
|
@ -116,10 +116,12 @@ wxString AddFileExtListToFilter( const std::vector<std::string>& aExts )
|
|||
return files_filter;
|
||||
}
|
||||
|
||||
const std::string BackupFileSuffix( "-bak" );
|
||||
|
||||
const std::string KiCadSymbolLibFileExtension( "kicad_sym" );
|
||||
const std::string SchematicSymbolFileExtension( "sym" );
|
||||
const std::string LegacySymbolLibFileExtension( "lib" );
|
||||
const std::string LegacySymbolDocumentFileExtension( "dcm" );
|
||||
|
||||
const std::string VrmlFileExtension( "wrl" );
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ bool DIALOG_SYMBOL_REMAP::backupProject( REPORTER& aReporter )
|
|||
}
|
||||
|
||||
// Back up the rescue symbol library document file if it exists.
|
||||
srcFileName.SetExt( "dcm" );
|
||||
srcFileName.SetExt( LegacySymbolDocumentFileExtension );
|
||||
destFileName.SetExt( srcFileName.GetExt() );
|
||||
|
||||
tmp.Printf( _( "Backing up file \"%s\" to file \"%s\"." ),
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include <kiface_ids.h>
|
||||
#include <netlist_exporters/netlist_exporter_kicad.h>
|
||||
#include <wx/ffile.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <schematic.h>
|
||||
#include <connection_graph.h>
|
||||
|
@ -310,7 +311,8 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
|
||||
destFile.SetPath( destPath );
|
||||
|
||||
if( ext == "sch" || ext == "sch-bak" || ext == "kicad_sch" || ext == "kicad_sch-bak" )
|
||||
if( ext == LegacySchematicFileExtension || ext == LegacySchematicFileExtension + BackupFileSuffix ||
|
||||
ext == KiCadSchematicFileExtension || ext == KiCadSchematicFileExtension + BackupFileSuffix )
|
||||
{
|
||||
if( destFile.GetName() == aProjectName )
|
||||
destFile.SetName( aNewProjectName );
|
||||
|
@ -326,19 +328,20 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aProje
|
|||
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "sym" )
|
||||
else if( ext == SchematicSymbolFileExtension )
|
||||
{
|
||||
// Symbols are not project-specific. Keep their source names.
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "lib" || ext == "dcm" || ext == "kicad_sym" )
|
||||
else if( ext == LegacySymbolLibFileExtension || ext == LegacySymbolDocumentFileExtension ||
|
||||
ext == KiCadSymbolLibFileExtension )
|
||||
{
|
||||
if( destFile.GetName() == aProjectName + "-cache" )
|
||||
destFile.SetName( aNewProjectName + "-cache" );
|
||||
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "net" )
|
||||
else if( ext == NetlistFileExtension )
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ SCH_SHEET* SCH_ALTIUM_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchem
|
|||
wxASSERT( !aFileName || aSchematic != NULL );
|
||||
|
||||
wxFileName fileName( aFileName );
|
||||
fileName.SetExt( ".kicad_sch" );
|
||||
fileName.SetExt( KiCadSchematicFileExtension );
|
||||
m_schematic = aSchematic;
|
||||
|
||||
// Delete on exception, if I own m_rootSheet, according to aAppendToMe
|
||||
|
@ -1987,7 +1987,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileName( const std::map<wxString, wxString>& aProp
|
|||
if( ( elem.text.Right( GetFileExtension().length() + 1 ).Lower() ) == ( "." + GetFileExtension().Lower() ))
|
||||
{
|
||||
elem.text.RemoveLast( 6 );
|
||||
elem.text += "kicad_sch";
|
||||
elem.text += KiCadSchematicFileExtension;
|
||||
}
|
||||
|
||||
filenameField.SetText( elem.text );
|
||||
|
|
|
@ -408,7 +408,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchema
|
|||
unique_ptr<SCH_SHEET> deleter( aAppendToMe ? nullptr : m_rootSheet );
|
||||
|
||||
wxFileName newFilename( m_filename );
|
||||
newFilename.SetExt( "kicad_sch" );
|
||||
newFilename.SetExt( KiCadSchematicFileExtension );
|
||||
|
||||
if( aAppendToMe )
|
||||
{
|
||||
|
@ -710,7 +710,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
|||
ReplaceIllegalFileNameChars( &filename );
|
||||
replace( filename.begin(), filename.end(), ' ', '_' );
|
||||
|
||||
wxString fn = wxString( filename + ".kicad_sch" );
|
||||
wxString fn = wxString( filename + "." + KiCadSchematicFileExtension );
|
||||
filenameField.SetText( fn );
|
||||
wxFileName fileName( fn );
|
||||
m_currentSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <dialogs/dialog_junction_props.h>
|
||||
#include <dialogs/dialog_sheet_pin_properties.h>
|
||||
#include <kicad_string.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
SCH_DRAWING_TOOLS::SCH_DRAWING_TOOLS() :
|
||||
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
|
||||
|
@ -1241,7 +1242,7 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
sheet->SetBorderColor( cfg->m_Drawing.default_sheet_border_color );
|
||||
sheet->SetBackgroundColor( cfg->m_Drawing.default_sheet_background_color );
|
||||
sheet->GetFields()[ SHEETNAME ].SetText( "Untitled Sheet" );
|
||||
sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled.kicad_sch" );
|
||||
sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled." + KiCadSchematicFileExtension );
|
||||
sizeSheet( sheet, cursorPos );
|
||||
|
||||
m_view->ClearPreview();
|
||||
|
|
|
@ -566,14 +566,6 @@ protected:
|
|||
///< Default style flags used for wxAUI toolbars.
|
||||
static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND;
|
||||
|
||||
/**
|
||||
* @return the suffix to be appended to the file extension on backup
|
||||
*/
|
||||
static wxString GetBackupSuffix()
|
||||
{
|
||||
return wxT( "-bak" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the string to prepend to a file name for automatic save.
|
||||
*/
|
||||
|
|
|
@ -109,8 +109,11 @@ wxString AddFileExtListToFilter( const std::vector<std::string>& aExts );
|
|||
*/
|
||||
wxString formatWildcardExt( const wxString& aWildcard );
|
||||
|
||||
extern const std::string BackupFileSuffix;
|
||||
|
||||
extern const std::string SchematicSymbolFileExtension;
|
||||
extern const std::string LegacySymbolLibFileExtension;
|
||||
extern const std::string LegacySymbolDocumentFileExtension;
|
||||
extern const std::string SchematicBackupFileExtension;
|
||||
|
||||
extern const std::string VrmlFileExtension;
|
||||
|
|
|
@ -366,42 +366,42 @@ public:
|
|||
// straight copy
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), m_errors );
|
||||
}
|
||||
else if( ext == "kicad_sch"
|
||||
|| ext == "kicad_sch-bak"
|
||||
|| ext == "sch"
|
||||
|| ext == "sch-bak"
|
||||
|| ext == "sym"
|
||||
|| ext == "lib"
|
||||
|| ext == "dcm"
|
||||
|| ext == "kicad_sym"
|
||||
|| ext == "net"
|
||||
else if( ext == KiCadSchematicFileExtension
|
||||
|| ext == KiCadSchematicFileExtension + BackupFileSuffix
|
||||
|| ext == LegacySchematicFileExtension
|
||||
|| ext == LegacySchematicFileExtension + BackupFileSuffix
|
||||
|| ext == SchematicSymbolFileExtension
|
||||
|| ext == LegacySymbolLibFileExtension
|
||||
|| ext == LegacySymbolDocumentFileExtension
|
||||
|| ext == KiCadSymbolLibFileExtension
|
||||
|| ext == NetlistFileExtension
|
||||
|| destFile.GetName() == "sym-lib-table" )
|
||||
{
|
||||
KIFACE* eeschema = m_frame->Kiway().KiFACE( KIWAY::FACE_SCH );
|
||||
eeschema->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
|
||||
m_newProjectName, aSrcFilePath, m_errors );
|
||||
}
|
||||
else if( ext == "kicad_pcb"
|
||||
|| ext == "kicad_pcb-bak"
|
||||
|| ext == "brd"
|
||||
|| ext == "kicad_mod"
|
||||
|| ext == "mod"
|
||||
|| ext == "cmp"
|
||||
else if( ext == KiCadPcbFileExtension
|
||||
|| ext == KiCadPcbFileExtension + BackupFileSuffix
|
||||
|| ext == LegacyPcbFileExtension
|
||||
|| ext == KiCadFootprintFileExtension
|
||||
|| ext == LegacyFootprintLibPathExtension
|
||||
|| ext == ComponentFileExtension
|
||||
|| destFile.GetName() == "fp-lib-table" )
|
||||
{
|
||||
KIFACE* pcbnew = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
|
||||
pcbnew->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
|
||||
m_newProjectName, aSrcFilePath, m_errors );
|
||||
}
|
||||
else if( ext == "kicad_wks" )
|
||||
else if( ext == PageLayoutDescrFileExtension )
|
||||
{
|
||||
KIFACE* pleditor = m_frame->Kiway().KiFACE( KIWAY::FACE_PL_EDITOR );
|
||||
pleditor->SaveFileAs( m_projectDirPath, m_projectName, m_newProjectDirPath,
|
||||
m_newProjectName, aSrcFilePath, m_errors );
|
||||
}
|
||||
else if( ext == "gbr"
|
||||
|| ext == "gbrjob"
|
||||
|| ext == "drl"
|
||||
else if( ext == GerberFileExtension
|
||||
|| ext == GerberJobFileExtension
|
||||
|| ext == DrillFileExtension
|
||||
|| IsProtelExtension( ext ) )
|
||||
{
|
||||
KIFACE* gerbview = m_frame->Kiway().KiFACE( KIWAY::FACE_GERBVIEW );
|
||||
|
|
|
@ -1414,11 +1414,11 @@ bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist, const wxStrin
|
|||
void PCB_EDIT_FRAME::RunEeschema()
|
||||
{
|
||||
wxString msg;
|
||||
wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(), "kicad_sch" );
|
||||
wxFileName schematic( Prj().GetProjectPath(), Prj().GetProjectName(), KiCadSchematicFileExtension );
|
||||
|
||||
if( !schematic.FileExists() )
|
||||
{
|
||||
wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(), "sch" );
|
||||
wxFileName legacySchematic( Prj().GetProjectPath(), Prj().GetProjectName(), LegacySchematicFileExtension );
|
||||
|
||||
if( legacySchematic.FileExists() )
|
||||
{
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <paths.h>
|
||||
#include "invoke_pcb_dialog.h"
|
||||
#include "dialog_global_fp_lib_table_config.h"
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
|
||||
namespace PCB {
|
||||
|
@ -415,26 +416,26 @@ void IFACE::SaveFileAs( const wxString& aProjectBasePath, const wxString& aSrcPr
|
|||
|
||||
destFile.SetPath( destPath );
|
||||
|
||||
if( ext == "kicad_pcb" || ext == "kicad_pcb-bak" )
|
||||
if( ext == KiCadPcbFileExtension || ext == KiCadPcbFileExtension + BackupFileSuffix )
|
||||
{
|
||||
if( destFile.GetName() == aSrcProjectName )
|
||||
destFile.SetName( aNewProjectName );
|
||||
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "brd" )
|
||||
else if( ext == LegacyPcbFileExtension )
|
||||
{
|
||||
if( destFile.GetName() == aSrcProjectName )
|
||||
destFile.SetName( aNewProjectName );
|
||||
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "mod" || ext == "kicad_mod" )
|
||||
else if( ext == LegacyFootprintLibPathExtension || ext == KiCadFootprintFileExtension )
|
||||
{
|
||||
// Footprints are not project-specific. Keep their source names.
|
||||
KiCopyFile( aSrcFilePath, destFile.GetFullPath(), aErrors );
|
||||
}
|
||||
else if( ext == "cmp" )
|
||||
else if( ext == ComponentFileExtension )
|
||||
{
|
||||
// JEY TODO
|
||||
}
|
||||
|
|
|
@ -79,10 +79,9 @@ void ScriptingSetPcbEditFrame( PCB_EDIT_FRAME* aPcbEditFrame )
|
|||
|
||||
BOARD* LoadBoard( wxString& aFileName )
|
||||
{
|
||||
if( aFileName.EndsWith( wxT( ".kicad_pcb" ) ) )
|
||||
if( aFileName.EndsWith( KiCadPcbFileExtension ) )
|
||||
return LoadBoard( aFileName, IO_MGR::KICAD_SEXP );
|
||||
|
||||
else if( aFileName.EndsWith( wxT( ".brd" ) ) )
|
||||
else if( aFileName.EndsWith( LegacyPcbFileExtension ) )
|
||||
return LoadBoard( aFileName, IO_MGR::LEGACY );
|
||||
|
||||
// as fall back for any other kind use the legacy format
|
||||
|
|
Loading…
Reference in New Issue