Commit 272f583d authored by Martino Facchin's avatar Martino Facchin Committed by Cristian Maglie

Recognize if IDE is portable and fix paths accordingly

parent 02ffe3cb
......@@ -39,6 +39,9 @@ type Configuration struct {
// ArduinoIDEDirectory is the directory of the Arduino IDE if the CLI runs together with it.
ArduinoIDEDirectory *paths.Path
// IsPortable is set to true if the cli lives in IDE directory and the IDE is portable
IsPortable bool
// downloadsDir is the directory where the package files are downloaded and cached.
// Use DownloadsDir() method to retrieve it.
downloadsDir *paths.Path
......
......@@ -62,6 +62,12 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
}
}
portable := "portable"
if ideDir.Join(portable).Exist() {
logrus.Info("IDE is portable")
config.IsPortable = true
}
config.ArduinoIDEDirectory = ideDir
res = true
return true
......@@ -70,6 +76,10 @@ func (config *Configuration) IsBundledInDesktopIDE() bool {
// LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file
func (config *Configuration) LoadFromDesktopIDEPreferences() error {
logrus.Info("Unserializing from IDE preferences")
if config.IsPortable {
config.DataDir = config.ArduinoIDEDirectory.Join("portable")
config.SketchbookDir = config.ArduinoIDEDirectory.Join("portable").Join("sketchbook")
}
preferenceTxtPath := config.DataDir.Join("preferences.txt")
props, err := properties.LoadFromPath(preferenceTxtPath)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment