@@ -64,9 +64,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
6464 }
6565
6666 // TODO: IS THIS CHECK NEEDED? can we ignore and let it fail at next ReadDir?
67- if isDir , err := path .IsDir (); err != nil {
68- return fmt .Errorf ("reading %s stat info: %s" , path , err )
69- } else if ! isDir {
67+ if ! path .IsDir () {
7068 return fmt .Errorf ("%s is not a directory" , path )
7169 }
7270
@@ -103,10 +101,10 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
103101 // in the latter case we just move into "hardware" directory and continue
104102 var architectureParentPath * paths.Path
105103 hardwareSubdirPath := packagerPath .Join ("hardware" ) // ex: .arduino15/packages/arduino/hardware
106- if isDir , _ := hardwareSubdirPath .IsDir (); isDir {
104+ if hardwareSubdirPath .IsDir () {
107105 // we found the "hardware" directory move down into that
108106 architectureParentPath = hardwareSubdirPath // ex: .arduino15/packages/arduino/
109- } else if isDir , _ := packagerPath .IsDir (); isDir {
107+ } else if packagerPath .IsDir () {
110108 // we are already at the correct level
111109 architectureParentPath = packagerPath
112110 } else {
@@ -122,7 +120,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
122120 // Check if we have tools to load, the directory structure is as follows:
123121 // - PACKAGER/tools/TOOL-NAME/TOOL-VERSION/... (ex: arduino/tools/bossac/1.7.0/...)
124122 toolsSubdirPath := packagerPath .Join ("tools" )
125- if isDir , _ := toolsSubdirPath .IsDir (); isDir {
123+ if toolsSubdirPath .IsDir () {
126124 pm .Log .Infof ("Checking existence of 'tools' path: %s" , toolsSubdirPath )
127125 if err := pm .loadToolsFromPackage (targetPackage , toolsSubdirPath ); err != nil {
128126 return fmt .Errorf ("loading tools from %s: %s" , toolsSubdirPath , err )
@@ -150,7 +148,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
150148 continue
151149 }
152150 platformPath := packageDir .Join (architecure )
153- if isDir , _ := platformPath .IsDir (); ! isDir {
151+ if ! platformPath .IsDir () {
154152 continue
155153 }
156154
@@ -159,7 +157,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
159157 // - ARCHITECTURE/VERSION/boards.txt
160158 // We identify them by checking where is the bords.txt file
161159 possibleBoardTxtPath := platformPath .Join ("boards.txt" )
162- if exist , err := possibleBoardTxtPath .Exist (); err != nil {
160+ if exist , err := possibleBoardTxtPath .ExistCheck (); err != nil {
163161
164162 return fmt .Errorf ("looking for boards.txt in %s: %s" , possibleBoardTxtPath , err )
165163
@@ -169,7 +167,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
169167 // this is an unversioned Platform
170168
171169 // FIXME: this check is duplicated, find a better way to handle this
172- if exist , err := platformPath .Join ("boards.txt" ).Exist (); err != nil {
170+ if exist , err := platformPath .Join ("boards.txt" ).ExistCheck (); err != nil {
173171 return fmt .Errorf ("opening boards.txt: %s" , err )
174172 } else if ! exist {
175173 continue
@@ -198,7 +196,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir
198196 versionDirs .FilterDirs ()
199197 versionDirs .FilterOutHiddenFiles ()
200198 for _ , versionDir := range versionDirs {
201- if exist , err := versionDir .Join ("boards.txt" ).Exist (); err != nil {
199+ if exist , err := versionDir .Join ("boards.txt" ).ExistCheck (); err != nil {
202200 return fmt .Errorf ("opening boards.txt: %s" , err )
203201 } else if ! exist {
204202 continue
0 commit comments