35
35
import java .io .ByteArrayOutputStream ;
36
36
import java .io .File ;
37
37
import java .io .IOException ;
38
+ import java .nio .file .Files ;
39
+ import java .nio .file .Path ;
40
+ import java .nio .file .Paths ;
38
41
import java .util .LinkedList ;
39
42
import java .util .List ;
40
43
import java .util .Map ;
@@ -54,7 +57,7 @@ public void init() throws IOException {
54
57
}
55
58
56
59
private void recoverSettingsFolderPath () throws IOException {
57
- String path = Advapi32Util .registryGetStringValue (WinReg .HKEY_CURRENT_USER , "Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Explorer\\ Shell Folders" , "AppData" );
60
+ String path = Advapi32Util .registryGetStringValue (WinReg .HKEY_CURRENT_USER , "Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Explorer\\ Shell Folders" , "Local AppData" );
58
61
this .settingsFolder = new File (path , "Arduino15" );
59
62
}
60
63
@@ -220,4 +223,23 @@ public void link(File something, File somewhere) throws IOException, Interrupted
220
223
221
224
public void chmod (File file , int mode ) throws IOException , InterruptedException {
222
225
}
226
+
227
+ @ Override
228
+ public void fixSettingsLocation () throws IOException {
229
+ String path = Advapi32Util .registryGetStringValue (WinReg .HKEY_CURRENT_USER , "Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Explorer\\ Shell Folders" , "AppData" );
230
+ Path previousSettingsFolder = Paths .get (path , "Arduino15" );
231
+ if (!Files .exists (previousSettingsFolder )) {
232
+ return ;
233
+ }
234
+
235
+ if (!Files .exists (previousSettingsFolder .resolve (Paths .get ("preferences.txt" )))) {
236
+ return ;
237
+ }
238
+
239
+ if (settingsFolder .exists ()) {
240
+ return ;
241
+ }
242
+
243
+ Files .move (previousSettingsFolder , settingsFolder .toPath ());
244
+ }
223
245
}
0 commit comments