mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Windows: migrating from AppData\Roaming\Arduino15 to AppData\Local\Arduino15.
Migration occurs when NO preferences file location is provided (CLI only), when new location does not exist and when there is something to migrate. Fixes #2902
This commit is contained in:
parent
62e5e0186f
commit
ea55a2edc3
@ -962,7 +962,7 @@ public class BaseNoGui {
|
||||
}
|
||||
}
|
||||
|
||||
static public void initParameters(String args[]) {
|
||||
static public void initParameters(String args[]) throws IOException {
|
||||
String preferencesFile = null;
|
||||
|
||||
// Do a first pass over the commandline arguments, the rest of them
|
||||
|
@ -245,4 +245,8 @@ public class Platform {
|
||||
Process process = Runtime.getRuntime().exec(new String[]{"chmod", Integer.toOctalString(mode), file.getAbsolutePath()}, null, null);
|
||||
process.waitFor();
|
||||
}
|
||||
|
||||
public void fixSettingsLocation() throws IOException {
|
||||
//noop
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ public class PreferencesData {
|
||||
static boolean doSave = true;
|
||||
|
||||
|
||||
static public void init(File file) {
|
||||
static public void init(File file) throws IOException {
|
||||
if (file == null) {
|
||||
BaseNoGui.getPlatform().fixSettingsLocation();
|
||||
}
|
||||
if (file != null) {
|
||||
preferencesFile = file;
|
||||
} else {
|
||||
|
@ -35,6 +35,9 @@ import processing.app.legacy.PConstants;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -54,7 +57,7 @@ public class Platform extends processing.app.Platform {
|
||||
}
|
||||
|
||||
private void recoverSettingsFolderPath() throws IOException {
|
||||
String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData");
|
||||
String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Local AppData");
|
||||
this.settingsFolder = new File(path, "Arduino15");
|
||||
}
|
||||
|
||||
@ -220,4 +223,23 @@ public class Platform extends processing.app.Platform {
|
||||
|
||||
public void chmod(File file, int mode) throws IOException, InterruptedException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixSettingsLocation() throws IOException {
|
||||
String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData");
|
||||
Path previousSettingsFolder = Paths.get(path, "Arduino15");
|
||||
if (!Files.exists(previousSettingsFolder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Files.exists(previousSettingsFolder.resolve(Paths.get("preferences.txt")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (settingsFolder.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Files.move(previousSettingsFolder, settingsFolder.toPath());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user