@@ -53,16 +53,12 @@ func (s *LibrariesBuilder) Run(ctx *types.Context) error {
5353 return nil
5454}
5555
56- func containsFile (folder * paths.Path ) bool {
57- res , _ := folder .ReadDir ()
58- hasfiles := false
59- for _ , el := range res {
60- if ! el .IsDir () {
61- hasfiles = true
62- break
63- }
56+ func directoryContainsFile (folder * paths.Path ) bool {
57+ if files , err := folder .ReadDir (); err == nil {
58+ files .FilterOutDirs ()
59+ return len (files ) > 0
6460 }
65- return hasfiles
61+ return false
6662}
6763
6864func findExpectedPrecompiledLibFolder (ctx * types.Context , library * libraries.Library ) * paths.Path {
@@ -98,15 +94,15 @@ func findExpectedPrecompiledLibFolder(ctx *types.Context, library *libraries.Lib
9894 if len (fpuSpecs ) > 0 {
9995 fpuSpecs = strings .TrimRight (fpuSpecs , "-" )
10096 fullPrecompDir := library .SourceDir .Join (mcu ).Join (fpuSpecs )
101- if fullPrecompDir .Exist () && containsFile (fullPrecompDir ) {
97+ if fullPrecompDir .Exist () && directoryContainsFile (fullPrecompDir ) {
10298 logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Using precompiled library in {0}" , fullPrecompDir )
10399 return fullPrecompDir
104100 }
105101 logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Precompiled library in \" {0}\" not found" , fullPrecompDir )
106102 }
107103
108104 precompDir := library .SourceDir .Join (mcu )
109- if precompDir .Exist () && containsFile (precompDir ) {
105+ if precompDir .Exist () && directoryContainsFile (precompDir ) {
110106 logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Using precompiled library in {0}" , precompDir )
111107 return precompDir
112108 }
0 commit comments