From 7ca6344b571f7d8e8b1339f5126c82ad99300c1f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 21 Nov 2023 09:24:14 +0100 Subject: [PATCH] Kicad PROJECT_ARCHIVER: better fix than commit 734e0ca0: Do not store twice files with extension .gm?? in zip files Previous commit did not store files like *.gm12, that can be existing when Gerber files come from another ECAD tool, and allowed duplicate files like *.g1 --- common/project/project_archiver.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/project/project_archiver.cpp b/common/project/project_archiver.cpp index ee296bd069..98d4306311 100644 --- a/common/project/project_archiver.cpp +++ b/common/project/project_archiver.cpp @@ -137,8 +137,10 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi wxT( "*.stp" ), wxT( "*.step" ), // 3d files wxT( "*.wrl" ), wxT( "*.g?" ), wxT( "*.g??" ), // Gerber files + wxT( "*.gm??"), // Some gerbers like .gm12 (from protel export) wxT( "*.gbrjob" ), // Gerber job files - wxT( "*.pos" ), wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab files + wxT( "*.pos" ), // our position files + wxT( "*.drl" ), wxT( "*.nc" ), wxT( "*.xnc" ), // Fab drill files wxT( "*.d356" ), wxT( "*.rpt" ), wxT( "*.net" ), @@ -197,8 +199,18 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi unsigned long uncompressedBytes = 0; + // Our filename collector can store duplicate filenames. for instance *.gm2 + // matches both *.g?? and *.gm??. + // So skip duplicate filenames (they are sorted, so it is easy. + wxString lastStoredFile; + for( unsigned ii = 0; ii < files.GetCount(); ii++ ) { + if( lastStoredFile == files[ii] ) // duplicate name: already stored + continue; + + lastStoredFile = files[ii]; + wxFileSystem fsfile; wxFileName curr_fn( files[ii] );