Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
2fbbafa0
Commit
2fbbafa0
authored
Jun 11, 2019
by
Piotr Henryk Dabrowski
Committed by
Massimiliano Pippi
Jun 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use os.UserHomeDir() for obtaining user's home directory (#239)
parent
17b110bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
33 deletions
+12
-33
configs/directories.go
configs/directories.go
+12
-33
No files found.
configs/directories.go
View file @
2fbbafa0
...
...
@@ -19,7 +19,7 @@ package configs
import
(
"fmt"
"os
/user
"
"os"
"runtime"
"github.com/arduino/go-paths-helper"
...
...
@@ -28,65 +28,44 @@ import (
// getDefaultConfigFilePath returns the default path for arduino-cli.yaml
func
getDefaultConfigFilePath
()
*
paths
.
Path
{
usr
,
err
:=
user
.
Current
()
arduinoDataDir
,
err
:=
getDefaultArduinoDataDir
()
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"retrieving user home dir: %s"
,
err
)
)
panic
(
err
)
}
arduinoDataDir
:=
paths
.
New
(
usr
.
HomeDir
)
switch
runtime
.
GOOS
{
case
"linux"
:
arduinoDataDir
=
arduinoDataDir
.
Join
(
".arduino15"
)
case
"darwin"
:
arduinoDataDir
=
arduinoDataDir
.
Join
(
"Library"
,
"arduino15"
)
case
"windows"
:
localAppDataPath
,
err
:=
win32
.
GetLocalAppDataFolder
()
if
err
!=
nil
{
panic
(
err
)
}
arduinoDataDir
=
paths
.
New
(
localAppDataPath
)
.
Join
(
"Arduino15"
)
default
:
panic
(
fmt
.
Errorf
(
"unsupported OS: %s"
,
runtime
.
GOOS
))
}
return
arduinoDataDir
.
Join
(
"arduino-cli.yaml"
)
}
func
getDefaultArduinoDataDir
()
(
*
paths
.
Path
,
error
)
{
us
r
,
err
:=
user
.
Current
()
us
erHomeDir
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"retrieving user home dir: %s"
,
err
)
return
nil
,
err
}
arduinoDataDir
:=
paths
.
New
(
usr
.
HomeDir
)
switch
runtime
.
GOOS
{
case
"linux"
:
arduinoDataDir
=
arduinoDataDir
.
Join
(
".arduino15"
)
return
paths
.
New
(
userHomeDir
)
.
Join
(
".arduino15"
),
nil
case
"darwin"
:
arduinoDataDir
=
arduinoDataDir
.
Join
(
"Library"
,
"arduino15"
)
return
paths
.
New
(
userHomeDir
)
.
Join
(
"Library"
,
"arduino15"
),
nil
case
"windows"
:
localAppDataPath
,
err
:=
win32
.
GetLocalAppDataFolder
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"getting LocalAppData path: %s"
,
err
)
}
arduinoDataDir
=
paths
.
New
(
localAppDataPath
)
.
Join
(
"Arduino15"
)
return
paths
.
New
(
localAppDataPath
)
.
Join
(
"Arduino15"
),
nil
default
:
return
nil
,
fmt
.
Errorf
(
"unsupported OS: %s"
,
runtime
.
GOOS
)
}
return
arduinoDataDir
,
nil
}
func
getDefaultSketchbookDir
()
(
*
paths
.
Path
,
error
)
{
us
r
,
err
:=
user
.
Current
()
us
erHomeDir
,
err
:=
os
.
UserHomeDir
()
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"retrieving home dir: %s"
,
err
)
return
nil
,
err
}
switch
runtime
.
GOOS
{
case
"linux"
:
return
paths
.
New
(
us
r
.
HomeDir
)
.
Join
(
"Arduino"
),
nil
return
paths
.
New
(
us
er
HomeDir
)
.
Join
(
"Arduino"
),
nil
case
"darwin"
:
return
paths
.
New
(
us
r
.
HomeDir
)
.
Join
(
"Documents"
,
"Arduino"
),
nil
return
paths
.
New
(
us
er
HomeDir
)
.
Join
(
"Documents"
,
"Arduino"
),
nil
case
"windows"
:
documentsPath
,
err
:=
win32
.
GetDocumentsFolder
()
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment