Skip to content

Commit 2a5a79d

Browse files
committed
go-paths-helper API change
1 parent 6515418 commit 2a5a79d

19 files changed

+80
-66
lines changed

Gopkg.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arduino/cores/cores.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (release *PlatformRelease) RuntimeProperties() properties.Map {
209209
// present
210210
func (release *PlatformRelease) GetLibrariesDir() *paths.Path {
211211
libDir := release.InstallDir.Join("libraries")
212-
if isDir, _ := libDir.IsDir(); isDir {
212+
if libDir.IsDir() {
213213
return libDir
214214
}
215215
return nil

arduino/cores/packagemanager/loader.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

arduino/libraries/librariesmanager/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
5050
libPath := libsDir.Join(utils.SanitizeName(indexLibrary.Library.Name))
5151
if replaced != nil && replaced.InstallDir.EquivalentTo(libPath) {
5252
formatter.Print(fmt.Sprintf("Replacing %s with %s", replaced, indexLibrary))
53-
} else if isdir, _ := libPath.IsDir(); isdir {
53+
} else if libPath.IsDir() {
5454
return nil, fmt.Errorf("destination dir %s already exists, cannot install", libPath)
5555
}
5656
return libPath, indexLibrary.Resource.Install(lm.DownloadsDir, libsDir, libPath)

arduino/libraries/loader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import (
2828

2929
// Load loads a library from the given LibraryLocation
3030
func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) {
31-
if exist, _ := libDir.Join("library.properties").Exist(); exist {
31+
if libDir.Join("library.properties").Exist() {
3232
return makeNewLibrary(libDir, location)
3333
}
3434
return makeLegacyLibrary(libDir, location)
3535
}
3636

3737
func addUtilityDirectory(library *Library) {
3838
utilitySourcePath := library.InstallDir.Join("utility")
39-
if isDir, _ := utilitySourcePath.IsDir(); isDir {
39+
if utilitySourcePath.IsDir() {
4040
library.UtilityDir = utilitySourcePath
4141
}
4242
}
@@ -60,7 +60,7 @@ func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library,
6060
library := &Library{}
6161
library.Location = location
6262
library.InstallDir = libraryDir
63-
if exist, _ := libraryDir.Join("src").Exist(); exist {
63+
if libraryDir.Join("src").Exist() {
6464
library.Layout = RecursiveLayout
6565
library.SourceDir = libraryDir.Join("src")
6666
} else {

arduino/resources/helpers.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ func (r *DownloadResource) IsCached(downloadDir *paths.Path) (bool, error) {
4141
if err != nil {
4242
return false, fmt.Errorf("getting archive path: %s", err)
4343
}
44-
exist, err := archivePath.Exist()
45-
if err != nil {
46-
return false, fmt.Errorf("checking archive existence: %s", err)
47-
}
48-
49-
return exist, nil
44+
return archivePath.Exist(), nil
5045
}
5146

5247
// Download a DownloadResource.

arduino/resources/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (release *DownloadResource) Install(downloadDir, tempPath, destDir *paths.P
7676
}()
7777

7878
// If the destination dir already exists remove it
79-
if isdir, _ := destDir.IsDir(); isdir {
79+
if destDir.IsDir() {
8080
destDir.RemoveAll()
8181
}
8282

@@ -110,7 +110,7 @@ func findPackageRoot(parent *paths.Path) (*paths.Path, error) {
110110
}
111111
var root *paths.Path
112112
for _, file := range files {
113-
if isdir, _ := file.IsDir(); !isdir {
113+
if !file.IsDir() {
114114
continue
115115
}
116116
if root == nil {

configs/hardware_directories.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ func (config *Configuration) HardwareDirectories() (paths.PathList, error) {
3535
}
3636
}
3737

38-
dir := config.PackagesDir()
39-
if isdir, _ := dir.IsDir(); isdir {
38+
if dir := config.PackagesDir(); dir.IsDir() {
4039
res.Add(dir)
4140
}
4241

43-
dir = config.SketchbookDir.Join("hardware")
44-
if isdir, _ := dir.IsDir(); isdir {
42+
if dir := config.SketchbookDir.Join("hardware"); dir.IsDir() {
4543
res.Add(dir)
4644
}
4745

configs/preferences_txt_serializer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func proxyConfigsFromIDEPrefs(props properties.Map) error {
130130
func IDEBundledLibrariesDir() *paths.Path {
131131
if IsBundledInDesktopIDE() {
132132
libDir := paths.New(*arduinoIDEDirectory, "libraries")
133-
if isDir, _ := libDir.IsDir(); isDir {
133+
if libDir.IsDir() {
134134
return libDir
135135
}
136136
}

vendor/github.com/arduino/arduino-builder/container_find_includes.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)