Skip to content

Commit 4431be4

Browse files
committed
Renamed 'folder' to 'directory'
Fix arduino#106
1 parent 1b8bf63 commit 4431be4

File tree

24 files changed

+127
-131
lines changed

24 files changed

+127
-131
lines changed

Gopkg.lock

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

arduino/cores/packagemanager/loader.go

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ import (
4545
func (pm *PackageManager) LoadHardware(config *configs.Configuration) error {
4646
dirs, err := config.HardwareDirectories()
4747
if err != nil {
48-
return fmt.Errorf("getting hardware folder: %s", err)
48+
return fmt.Errorf("getting hardware directory: %s", err)
4949
}
5050
if err := pm.LoadHardwareFromDirectories(dirs); err != nil {
5151
return err
5252
}
5353
dirs, err = configs.BundleToolsDirectories()
5454
if err != nil {
55-
return fmt.Errorf("getting hardware folder: %s", err)
55+
return fmt.Errorf("getting hardware directory: %s", err)
5656
}
5757
return pm.LoadToolsFromBundleDirectories(dirs)
5858
}
@@ -78,10 +78,10 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
7878
if isDir, err := path.IsDir(); err != nil {
7979
return fmt.Errorf("reading %s stat info: %s", path, err)
8080
} else if !isDir {
81-
return fmt.Errorf("%s is not a folder", path)
81+
return fmt.Errorf("%s is not a directory", path)
8282
}
8383

84-
// Scan subfolders.
84+
// Scan subdirs
8585
files, err := path.ReadDir()
8686
if err != nil {
8787
return fmt.Errorf("reading %s directory: %s", path, err)
@@ -90,9 +90,9 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
9090
for _, packagerPath := range files {
9191
packager := packagerPath.Base()
9292

93-
// First exclude all "tools" folders
93+
// First exclude all "tools" directory
9494
if packager == "tools" {
95-
pm.Log.Infof("Excluding folder: %s", packagerPath)
95+
pm.Log.Infof("Excluding directory: %s", packagerPath)
9696
continue
9797
}
9898

@@ -102,7 +102,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
102102
return fmt.Errorf("following possible symlink %s: %s", path, err)
103103
}
104104

105-
// There are two possible package folder structures:
105+
// There are two possible package directory structures:
106106
// - PACKAGER/ARCHITECTURE-1/boards.txt... (ex: arduino/avr/...)
107107
// PACKAGER/ARCHITECTURE-2/boards.txt... (ex: arduino/sam/...)
108108
// PACKAGER/ARCHITECTURE-3/boards.txt... (ex: arduino/samd/...)
@@ -111,11 +111,11 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
111111
// PACKAGER/hardware/ARCHITECTURE-2/VERSION/boards.txt... (ex: arduino/hardware/sam/1.6.6/...)
112112
// PACKAGER/hardware/ARCHITECTURE-3/VERSION/boards.txt... (ex: arduino/hardware/samd/1.6.12/...)
113113
// PACKAGER/tools/... (ex: arduino/tools/...)
114-
// in the latter case we just move into "hardware" folder and continue
114+
// in the latter case we just move into "hardware" directory and continue
115115
var architectureParentPath *paths.Path
116116
hardwareSubdirPath := packagerPath.Join("hardware") // ex: .arduino15/packages/arduino/hardware
117117
if isDir, _ := hardwareSubdirPath.IsDir(); isDir {
118-
// we found the "hardware" folder move down into that
118+
// we found the "hardware" directory move down into that
119119
architectureParentPath = hardwareSubdirPath // ex: .arduino15/packages/arduino/
120120
} else if isDir, _ := packagerPath.IsDir(); isDir {
121121
// we are already at the correct level
@@ -130,7 +130,7 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
130130
return fmt.Errorf("loading package %s: %s", packager, err)
131131
}
132132

133-
// Check if we have tools to load, the folder structure is as follows:
133+
// Check if we have tools to load, the directory structure is as follows:
134134
// - PACKAGER/tools/TOOL-NAME/TOOL-VERSION/... (ex: arduino/tools/bossac/1.7.0/...)
135135
toolsSubdirPath := packagerPath.Join("tools")
136136
if isDir, _ := toolsSubdirPath.IsDir(); isDir {
@@ -146,18 +146,12 @@ func (pm *PackageManager) LoadHardwareFromDirectory(path *paths.Path) error {
146146

147147
// loadPlatforms load plaftorms from the specified directory assuming that they belongs
148148
// to the targetPackage object passed as parameter.
149-
func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFolder *paths.Path) error {
150-
pm.Log.Infof("Loading package %s from: %s", targetPackage.Name, packageFolder)
149+
func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageDir *paths.Path) error {
150+
pm.Log.Infof("Loading package %s from: %s", targetPackage.Name, packageDir)
151151

152-
// packagePlatformTxt, err := properties.SafeLoad(filepath.Join(folder, constants.FILE_PLATFORM_TXT))
153-
// if err != nil {
154-
// return err
155-
// }
156-
// targetPackage.Properties.Merge(packagePlatformTxt)
157-
158-
files, err := packageFolder.ReadDir()
152+
files, err := packageDir.ReadDir()
159153
if err != nil {
160-
return fmt.Errorf("reading directory %s: %s", packageFolder, err)
154+
return fmt.Errorf("reading directory %s: %s", packageDir, err)
161155
}
162156

163157
for _, file := range files {
@@ -166,12 +160,12 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFol
166160
architecure == "platform.txt" { // TODO: Check if this "platform.txt" condition should be here....
167161
continue
168162
}
169-
platformPath := packageFolder.Join(architecure)
163+
platformPath := packageDir.Join(architecure)
170164
if isDir, _ := platformPath.IsDir(); !isDir {
171165
continue
172166
}
173167

174-
// There are two possible platform folder structures:
168+
// There are two possible platform directory structures:
175169
// - ARCHITECTURE/boards.txt
176170
// - ARCHITECTURE/VERSION/boards.txt
177171
// We identify them by checking where is the bords.txt file
@@ -202,7 +196,7 @@ func (pm *PackageManager) loadPlatforms(targetPackage *cores.Package, packageFol
202196
} else /* !exist */ {
203197

204198
// case: ARCHITECTURE/VERSION/boards.txt
205-
// let's dive into VERSION folders
199+
// let's dive into VERSION directories
206200

207201
platform := targetPackage.GetOrCreatePlatform(architecure)
208202
versionDirs, err := platformPath.ReadDir()
@@ -332,7 +326,6 @@ func (pm *PackageManager) loadToolReleasesFromTool(tool *cores.Tool, toolPath *p
332326
version := versionPath.Base()
333327
if toolReleasePath, err := versionPath.Abs(); err == nil {
334328
release := tool.GetOrCreateRelease(version)
335-
// TODO: Make Folder a *paths.Path
336329
release.InstallDir = toolReleasePath
337330
pm.Log.WithField("tool", release).Infof("Loaded tool")
338331
} else {
@@ -358,7 +351,7 @@ func (pm *PackageManager) LoadToolsFromBundleDirectory(toolsPath *paths.Path) er
358351
// We scan toolsPath content to find a "builtin_tools_versions.txt", if such file exists
359352
// then the all the tools are available in the same directory, mixed together, and their
360353
// name and version are written in the "builtin_tools_versions.txt" file.
361-
// If no "builtin_tools_versions.txt" is found, then the folder structure is the classic
354+
// If no "builtin_tools_versions.txt" is found, then the directory structure is the classic
362355
// TOOLSPATH/TOOL-NAME/TOOL-VERSION and it will be parsed as such and associated to an
363356
// "unnamed" packager.
364357

arduino/cores/packagemanager/package_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func (pm *PackageManager) FindToolsRequiredForBoard(board *cores.Board) ([]*core
372372
foundTools := map[string]*cores.ToolRelease{}
373373

374374
// a Platform may not specify required tools (because it's a platform that comes from a
375-
// sketchbook/hardware folder without a package_index.json) then add all available tools
375+
// sketchbook/hardware dir without a package_index.json) then add all available tools
376376
for _, targetPackage := range pm.packages.Packages {
377377
for _, tool := range targetPackage.Tools {
378378
rel := tool.GetLatestInstalled()

arduino/libraries/libraries_layout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ import (
3838
type LibraryLayout uint16
3939

4040
const (
41-
// FlatLayout is a library without a `src` folder
41+
// FlatLayout is a library without a `src` directory
4242
FlatLayout LibraryLayout = 1 << iota
43-
// RecursiveLayout is a library with `src` folder (that allows recursive build)
43+
// RecursiveLayout is a library with `src` directory (that allows recursive build)
4444
RecursiveLayout
4545
)
4646

arduino/libraries/librariesmanager/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (lm *LibrariesManager) Install(indexLibrary *librariesindex.Release) (*path
5858

5959
libsDir := lm.getSketchbookLibrariesDir()
6060
if libsDir == nil {
61-
return nil, fmt.Errorf("sketchbook folder not set")
61+
return nil, fmt.Errorf("sketchbook directory not set")
6262
}
6363

6464
libPath := libsDir.Join(utils.SanitizeName(indexLibrary.Library.Name))

arduino/libraries/librariesmanager/librariesmanager.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (sc *LibrariesManager) AddLibrariesDir(path *paths.Path, location libraries
143143
})
144144
}
145145

146-
// AddPlatformReleaseLibrariesDir add the libraries folder in the
146+
// AddPlatformReleaseLibrariesDir add the libraries directory in the
147147
// specified PlatformRelease to the list of directories to scan when
148148
// searching for libraries.
149149
func (sc *LibrariesManager) AddPlatformReleaseLibrariesDir(plaftormRelease *cores.PlatformRelease, location libraries.LibraryLocation) {
@@ -186,20 +186,20 @@ func (sc *LibrariesManager) getSketchbookLibrariesDir() *paths.Path {
186186
// LoadLibrariesFromDir loads all libraries in the given directory. Returns
187187
// nil if the directory doesn't exists.
188188
func (sc *LibrariesManager) LoadLibrariesFromDir(librariesDir *LibrariesDir) error {
189-
subFolders, err := librariesDir.Path.ReadDir()
189+
subDirs, err := librariesDir.Path.ReadDir()
190190
if os.IsNotExist(err) {
191191
return nil
192192
}
193193
if err != nil {
194194
return fmt.Errorf("reading dir %s: %s", librariesDir.Path, err)
195195
}
196-
subFolders.FilterDirs()
197-
subFolders.FilterOutHiddenFiles()
196+
subDirs.FilterDirs()
197+
subDirs.FilterOutHiddenFiles()
198198

199-
for _, subFolder := range subFolders {
200-
library, err := libraries.Load(subFolder, librariesDir.Location)
199+
for _, subDir := range subDirs {
200+
library, err := libraries.Load(subDir, librariesDir.Location)
201201
if err != nil {
202-
return fmt.Errorf("loading library from %s: %s", subFolder, err)
202+
return fmt.Errorf("loading library from %s: %s", subDir, err)
203203
}
204204
library.ContainerPlatform = librariesDir.PlatformRelease
205205
alternatives, ok := sc.Libraries[library.Name]

arduino/libraries/lint.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ package libraries
3232
// Lint produce warnings about the formal correctness of a Library
3333
func (l *Library) Lint() ([]string, error) {
3434

35-
// TODO: check for spurious folders
36-
// subFolders, err := ioutil.ReadDir(libraryFolder)
35+
// TODO: check for spurious dirs
36+
// subDirs, err := ioutil.ReadDir(libraryDir)
3737
// if err != nil {
38-
// return nil, fmt.Errorf("reading dir %s: %s", libraryFolder, err)
38+
// return nil, fmt.Errorf("reading dir %s: %s", libraryDir, err)
3939
// }
40-
// for _, subFolder := range subFolders {
41-
// if utils.IsSCCSOrHiddenFile(subFolder) {
42-
// if !utils.IsSCCSFile(subFolder) && utils.IsHiddenFile(subFolder) {
40+
// for _, subDir := range subDirs {
41+
// if utils.IsSCCSOrHiddenFile(subDir) {
42+
// if !utils.IsSCCSFile(subDir) && utils.IsHiddenFile(subDir) {
4343
// logger.Fprintln(os.Stdout, "warn",
44-
// "WARNING: Spurious {0} folder in '{1}' library",
45-
// filepath.Base(subFolder.Name()), libProperties["name"])
44+
// "WARNING: Spurious {0} directory in '{1}' library",
45+
// filepath.Base(subDir.Name()), libProperties["name"])
4646
// }
4747
// }
4848
// }

arduino/libraries/loader.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ import (
3737
properties "github.com/arduino/go-properties-map"
3838
)
3939

40-
// Load loads a library from the given folder
40+
// Load loads a library from the given LibraryLocation
4141
func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) {
4242
if exist, _ := libDir.Join("library.properties").Exist(); exist {
4343
return makeNewLibrary(libDir, location)
4444
}
4545
return makeLegacyLibrary(libDir, location)
4646
}
4747

48-
func addUtilityFolder(library *Library) {
48+
func addUtilityDirectory(library *Library) {
4949
utilitySourcePath := library.InstallDir.Join("utility")
5050
if isDir, _ := utilitySourcePath.IsDir(); isDir {
5151
library.UtilityDir = utilitySourcePath
5252
}
5353
}
5454

55-
func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Library, error) {
56-
libProperties, err := properties.Load(libraryFolder.Join("library.properties").String())
55+
func makeNewLibrary(libraryDir *paths.Path, location LibraryLocation) (*Library, error) {
56+
libProperties, err := properties.Load(libraryDir.Join("library.properties").String())
5757
if err != nil {
5858
return nil, fmt.Errorf("loading library.properties: %s", err)
5959
}
@@ -70,14 +70,14 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
7070

7171
library := &Library{}
7272
library.Location = location
73-
library.InstallDir = libraryFolder
74-
if exist, _ := libraryFolder.Join("src").Exist(); exist {
73+
library.InstallDir = libraryDir
74+
if exist, _ := libraryDir.Join("src").Exist(); exist {
7575
library.Layout = RecursiveLayout
76-
library.SourceDir = libraryFolder.Join("src")
76+
library.SourceDir = libraryDir.Join("src")
7777
} else {
7878
library.Layout = FlatLayout
79-
library.SourceDir = libraryFolder
80-
addUtilityFolder(library)
79+
library.SourceDir = libraryDir
80+
addUtilityDirectory(library)
8181
}
8282

8383
if libProperties["architectures"] == "" {
@@ -99,7 +99,7 @@ func makeNewLibrary(libraryFolder *paths.Path, location LibraryLocation) (*Libra
9999
}
100100
library.License = libProperties["license"]
101101

102-
library.Name = libraryFolder.Base()
102+
library.Name = libraryDir.Base()
103103
library.RealName = strings.TrimSpace(libProperties["name"])
104104
library.Version = strings.TrimSpace(libProperties["version"])
105105
library.Author = strings.TrimSpace(libProperties["author"])
@@ -126,6 +126,6 @@ func makeLegacyLibrary(path *paths.Path, location LibraryLocation) (*Library, er
126126
Architectures: []string{"*"},
127127
IsLegacy: true,
128128
}
129-
addUtilityFolder(library)
129+
addUtilityDirectory(library)
130130
return library, nil
131131
}

arduino/resources/install.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99
)
1010

1111
// Install installs the resource in three steps:
12-
// - the archive is unpacked in a temporary subfolder of tempPath
13-
// - there should be only one root folder in the unpacked content
14-
// - the only root folder is moved/renamed to/as the destination directory
12+
// - the archive is unpacked in a temporary subdir of tempPath
13+
// - there should be only one root dir in the unpacked content
14+
// - the only root dir is moved/renamed to/as the destination directory
1515
// Note that tempPath and destDir must be on the same filesystem partition
1616
// otherwise the last step will fail.
1717
func (release *DownloadResource) Install(downloadDir, tempPath, destDir *paths.Path) error {
18-
// Create a temporary folder to extract package
18+
// Create a temporary dir to extract package
1919
if err := tempPath.MkdirAll(); err != nil {
2020
return fmt.Errorf("creating temp dir for extraction: %s", err)
2121
}

commands/commands.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ const (
5454
ErrNoConfigFile
5555
ErrBadCall
5656
ErrNetwork
57-
ErrCoreConfig // Represents an error in the cli core config, for example some basic files shipped with the installation are missing, or cannot create or get basic folder vital for the CLI to work.
57+
// ErrCoreConfig represents an error in the cli core config, for example some basic
58+
// files shipped with the installation are missing, or cannot create or get basic
59+
// directories vital for the CLI to work.
60+
ErrCoreConfig
5861
ErrBadArgument
5962

6063
Version = "0.1.0-alpha.preview"

commands/commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func TestCoreDownload(t *testing.T) {
285285
defer makeTempDataDir(t)()
286286
defer makeTempSketchbookDir(t)()
287287

288-
// Set staging folder to a temporary folder
288+
// Set staging dir to a temporary dir
289289
tmp, err := ioutil.TempDir(os.TempDir(), "test")
290290
require.NoError(t, err, "making temporary staging dir")
291291
defer os.RemoveAll(tmp)

0 commit comments

Comments
 (0)