mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
Merge pull request #3404 from ffissore/windows-appdata
Windows: new Arduino15 location and automatic migration
This commit is contained in:
commit
039edca39b
@ -962,7 +962,7 @@ public class BaseNoGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void initParameters(String args[]) {
|
static public void initParameters(String args[]) throws IOException {
|
||||||
String preferencesFile = null;
|
String preferencesFile = null;
|
||||||
|
|
||||||
// Do a first pass over the commandline arguments, the rest of them
|
// 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 process = Runtime.getRuntime().exec(new String[]{"chmod", Integer.toOctalString(mode), file.getAbsolutePath()}, null, null);
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fixSettingsLocation() throws IOException {
|
||||||
|
//noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,10 @@ public class PreferencesData {
|
|||||||
static boolean doSave = true;
|
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) {
|
if (file != null) {
|
||||||
preferencesFile = file;
|
preferencesFile = file;
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,6 +35,9 @@ import processing.app.legacy.PConstants;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -54,7 +57,7 @@ public class Platform extends processing.app.Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void recoverSettingsFolderPath() throws IOException {
|
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");
|
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 {
|
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