diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index baefbd81db..aa13749ce6 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -1366,7 +1366,7 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName ) wxFileName autoSaveFileName = aFileName; // Check for auto save file. - autoSaveFileName.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() ); + autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() ); wxLogTrace( traceAutoSave, wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() ); @@ -1413,7 +1413,7 @@ void EDA_BASE_FRAME::DeleteAutoSaveFile( const wxFileName& aFileName ) wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) ); wxFileName autoSaveFn = aFileName; - autoSaveFn.SetName( GetAutoSaveFilePrefix() + aFileName.GetName() ); + autoSaveFn.SetName( FILEEXT::AutoSaveFilePrefix + aFileName.GetName() ); if( autoSaveFn.FileExists() ) { diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index fcae910376..db289a9847 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -125,6 +125,7 @@ wxString AddFileExtListToFilter( const std::vector& aExts ) const std::string FILEEXT::BackupFileSuffix( "-bak" ); const std::string FILEEXT::LockFilePrefix( "~" ); const std::string FILEEXT::LockFileExtension( "lck" ); +const std::string FILEEXT::AutoSaveFilePrefix( "_autosave-" ); const std::string FILEEXT::KiCadSymbolLibFileExtension( "kicad_sym" ); const std::string FILEEXT::SchematicSymbolFileExtension( "sym" ); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 588f5d92ea..1a5db21701 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -894,7 +894,7 @@ bool SCH_EDIT_FRAME::saveSchematicFile( SCH_SHEET* aSheet, const wxString& aSave { // Delete auto save file. wxFileName autoSaveFileName = schematicFileName; - autoSaveFileName.SetName( GetAutoSaveFilePrefix() + schematicFileName.GetName() ); + autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + schematicFileName.GetName() ); if( autoSaveFileName.FileExists() ) { @@ -1324,7 +1324,7 @@ bool SCH_EDIT_FRAME::doAutoSave() tmpFileName = fn = screens.GetScreen( i )->GetFileName(); // Auto save file name is the normal file name prefixed with GetAutoSavePrefix(). - fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() ); + fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() ); if( saveSchematicFile( screens.GetSheet( i ), fn.GetFullPath() ) ) { @@ -1554,7 +1554,7 @@ bool SCH_EDIT_FRAME::updateAutoSaveFile() fn = screens.GetScreen( i )->GetFileName(); // Auto save file name is the normal file name prefixed with GetAutoSavePrefix(). - fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() ); + fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() ); autoSavedFiles.emplace_back( fn.GetFullPath() ); } @@ -1643,7 +1643,7 @@ void SCH_EDIT_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName ) wxString tmp = recoveredFn.GetName(); // Strip "_autosave-" prefix from the auto save file name. - tmp.Replace( GetAutoSaveFilePrefix(), wxS( "" ), false ); + tmp.Replace( FILEEXT::AutoSaveFilePrefix, wxS( "" ), false ); recoveredFn.SetName( tmp ); wxFileName backupFn = recoveredFn; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index cf4912ad63..51762ada4c 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1072,8 +1072,8 @@ void SCH_EDIT_FRAME::doCloseWindow() { fn = Prj().AbsolutePath( screen->GetFileName() ); - // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix(). - fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() ); + // Auto save file name is the normal file name prepended with FILEEXT::AutoSaveFilePrefix. + fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() ); if( fn.IsFileWritable() ) wxRemoveFile( fn.GetFullPath() ); diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index e92a95592b..6a9be60187 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -611,14 +611,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 string to prepend to a file name for automatic save. - */ - static wxString GetAutoSaveFilePrefix() - { - return wxT( "_autosave-" ); - } - virtual void doReCreateMenuBar() {} /** diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 6a474f76b2..0cfb9240d6 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -116,6 +116,7 @@ public: static const std::string BackupFileSuffix; static const std::string LockFilePrefix; static const std::string LockFileExtension; + static const std::string AutoSaveFilePrefix; static const std::string SchematicSymbolFileExtension; static const std::string LegacySymbolLibFileExtension; diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp index 809ac432da..cfcc188aab 100644 --- a/kicad/project_template.cpp +++ b/kicad/project_template.cpp @@ -85,7 +85,8 @@ public: wxString path( fn.GetPathWithSep() ); bool exclude = fn.GetName().Contains( "fp-info-cache" ) - || fn.GetName().StartsWith( "_autosave-" ) || fn.GetExt().Contains( "lck" ); + || fn.GetName().StartsWith( FILEEXT::AutoSaveFilePrefix ) + || fn.GetExt().Contains( "lck" ); if( !exclude ) m_files.emplace_back( wxFileName( filename ) ); diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 11e80246f0..73dd70d692 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -325,7 +325,7 @@ void PCB_EDIT_FRAME::OnExportSTEP( wxCommandEvent& event ) } // Use auto-saved board for export - brdFile.SetName( GetAutoSaveFilePrefix() + brdFile.GetName() ); + brdFile.SetName( FILEEXT::AutoSaveFilePrefix + brdFile.GetName() ); } DIALOG_EXPORT_STEP dlg( this, brdFile.GetFullPath() ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index b26ae0d97f..426cd291f5 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -291,7 +291,7 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id ) wxFileName currfn = Prj().AbsolutePath( GetBoard()->GetFileName() ); wxFileName fn = currfn; - wxString rec_name = GetAutoSaveFilePrefix() + fn.GetName(); + wxString rec_name = FILEEXT::AutoSaveFilePrefix + fn.GetName(); fn.SetName( rec_name ); if( !fn.FileExists() ) @@ -1061,7 +1061,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory, // Delete auto save file on successful save. wxFileName autoSaveFileName = pcbFileName; - autoSaveFileName.SetName( GetAutoSaveFilePrefix() + pcbFileName.GetName() ); + autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + pcbFileName.GetName() ); if( autoSaveFileName.FileExists() ) wxRemoveFile( autoSaveFileName.GetFullPath() ); @@ -1169,7 +1169,7 @@ bool PCB_EDIT_FRAME::doAutoSave() wxFileName autoSaveFileName = tmpFileName; // Auto save file name is the board file name prepended with autosaveFilePrefix string. - autoSaveFileName.SetName( GetAutoSaveFilePrefix() + autoSaveFileName.GetName() ); + autoSaveFileName.SetName( FILEEXT::AutoSaveFilePrefix + autoSaveFileName.GetName() ); if( !autoSaveFileName.IsOk() ) return false; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index cf72f730b6..c7748af21a 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1192,8 +1192,8 @@ void PCB_EDIT_FRAME::doCloseWindow() // Delete the auto save file if it exists. wxFileName fn = GetBoard()->GetFileName(); - // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'. - fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() ); + // Auto save file name is the normal file name prefixed with 'FILEEXT::AutoSaveFilePrefix'. + fn.SetName( FILEEXT::AutoSaveFilePrefix + fn.GetName() ); // When the auto save feature does not have write access to the board file path, it falls // back to a platform specific user temporary file path.