From 4bf75de6fd4ad37f158fb94913c9fdd186d5b191 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sun, 19 Nov 2023 10:48:17 -0500 Subject: [PATCH] Don't copy hidden files and folders when creating project from template. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16093 (cherry picked from commit a309e24132603d74579b894d96017b5fd639c2c8) --- kicad/project_template.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp index bf951fcddb..ce9cdf8e59 100644 --- a/kicad/project_template.cpp +++ b/kicad/project_template.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 Brian Sidebotham - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -81,7 +81,11 @@ public: virtual wxDirTraverseResult OnFile( const wxString& filename ) override { - if( !filename.StartsWith( m_exclude ) ) + wxFileName fn( filename ); + + bool exclude = filename.StartsWith( m_exclude ) || fn.GetName().StartsWith( wxS( "." ) ); + + if( !exclude ) m_files.emplace_back( wxFileName( filename ) ); return wxDIR_CONTINUE; @@ -89,7 +93,12 @@ public: virtual wxDirTraverseResult OnDir( const wxString& dirname ) override { - if( !dirname.StartsWith( m_exclude ) ) + wxFileName fn( dirname, wxEmptyString ); + wxArrayString dirs = fn.GetDirs(); + wxString lastDir = dirs[ fn.GetDirCount() - 1 ]; + bool exclude = dirname.StartsWith( m_exclude ) || lastDir.StartsWith( wxS( "." ) ); + + if( !exclude ) m_files.emplace_back( wxFileName::DirName( dirname ) ); return wxDIR_CONTINUE;