42 static const wxString kicadEntries[] = {
43 wxS(
".history/" ), wxS(
"*-backups/" ), wxS(
"_autosave-*" ),
44 wxS(
"fp-info-cache" ), wxS(
"~*.lck" ), wxS(
"*.kicad_prl" ),
47 wxFileName ignoreFile( aProjectPath, wxS(
".gitignore" ) );
48 std::set<wxString> existing;
49 bool fileExists = ignoreFile.FileExists();
50 bool hasTrailingNewline =
true;
54 wxFFile in( ignoreFile.GetFullPath(), wxT(
"r" ) );
57 if( !in.IsOpened() || !in.ReadAll( &contents ) )
60 hasTrailingNewline = contents.empty() || contents.EndsWith( wxS(
"\n" ) );
62 wxStringTokenizer tok( contents, wxS(
"\n" ) );
64 while( tok.HasMoreTokens() )
66 wxString line = tok.GetNextToken();
67 line.Trim().Trim(
false );
69 if( !line.empty() && !line.StartsWith( wxS(
"#" ) ) )
70 existing.insert( line );
76 for(
const wxString& entry : kicadEntries )
78 if( existing.find( entry ) == existing.end() )
79 missing += entry + wxS(
"\n" );
85 wxFFile out( ignoreFile.GetFullPath(), wxT(
"a" ) );
91 out.Write( wxS(
"# KiCad-generated files and directories.\n" ) );
92 else if( !hasTrailingNewline )
93 out.Write( wxS(
"\n" ) );
wxString result
Test unit parsing edge cases and error handling.