@@ -53,16 +53,12 @@ func (s *LibrariesBuilder) Run(ctx *types.Context) error {
53
53
return nil
54
54
}
55
55
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
64
60
}
65
- return hasfiles
61
+ return false
66
62
}
67
63
68
64
func findExpectedPrecompiledLibFolder (ctx * types.Context , library * libraries.Library ) * paths.Path {
@@ -98,15 +94,15 @@ func findExpectedPrecompiledLibFolder(ctx *types.Context, library *libraries.Lib
98
94
if len (fpuSpecs ) > 0 {
99
95
fpuSpecs = strings .TrimRight (fpuSpecs , "-" )
100
96
fullPrecompDir := library .SourceDir .Join (mcu ).Join (fpuSpecs )
101
- if fullPrecompDir .Exist () && containsFile (fullPrecompDir ) {
97
+ if fullPrecompDir .Exist () && directoryContainsFile (fullPrecompDir ) {
102
98
logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Using precompiled library in {0}" , fullPrecompDir )
103
99
return fullPrecompDir
104
100
}
105
101
logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Precompiled library in \" {0}\" not found" , fullPrecompDir )
106
102
}
107
103
108
104
precompDir := library .SourceDir .Join (mcu )
109
- if precompDir .Exist () && containsFile (precompDir ) {
105
+ if precompDir .Exist () && directoryContainsFile (precompDir ) {
110
106
logger .Fprintln (os .Stdout , constants .LOG_LEVEL_INFO , "Using precompiled library in {0}" , precompDir )
111
107
return precompDir
112
108
}
0 commit comments