13
13
14
14
import java .io .File ;
15
15
import java .io .FileInputStream ;
16
- import java .io .FileNotFoundException ;
17
16
import java .io .FileOutputStream ;
18
17
import java .io .FileReader ;
19
18
import java .io .IOException ;
20
19
import java .io .InputStream ;
21
- import java .io .PrintWriter ;
22
20
import java .io .Reader ;
23
- import java .io .UnsupportedEncodingException ;
24
21
import java .net .URL ;
25
22
import java .nio .file .Files ;
26
23
import java .nio .file .Path ;
@@ -165,49 +162,15 @@ static public IStatus downloadAndInstall(ArduinoPlatform platform, boolean force
165
162
}
166
163
167
164
} catch (IOException e ) {
168
- mstatus .add (
169
- new Status (IStatus .ERROR , Activator .getId (), Messages .ArduinoManager_Downloading_make_exe , e ));
165
+ mstatus .add (new Status (IStatus .ERROR , Activator .getId (), Messages .Manager_Downloading_make_exe , e ));
170
166
}
171
167
}
172
168
173
- mstatus .add (make_eclipse_plugin_txt_file (platform ));
169
+ // mstatus.add(make_eclipse_plugin_txt_file(platform));
174
170
return mstatus .getChildren ().length == 0 ? Status .OK_STATUS : mstatus ;
175
171
176
172
}
177
173
178
- static public IStatus make_eclipse_plugin_txt_file (ArduinoPlatform platform ) {
179
-
180
- // make a platform_plugin.txt file to store the tool paths
181
- File pluginFile = ConfigurationPreferences .getPlugin_Platform_File ();
182
-
183
- try (PrintWriter writer = new PrintWriter (pluginFile , "UTF-8" );) {
184
-
185
- writer .println ("#This is a automatically generated file by the Arduino eclipse plugin" ); //$NON-NLS-1$
186
- writer .println ("#only edit if you know what you are doing" ); //$NON-NLS-1$
187
- writer .println ("#Have fun" ); //$NON-NLS-1$
188
- writer .println ("#Jantje" ); //$NON-NLS-1$
189
- writer .println ();
190
-
191
- // TODO there should be a get tools and then loop over the tools as
192
- // this implementation returns the tools several times
193
- for (ArduinoPlatform curplatform : getPlatforms ()) {
194
- for (ToolDependency tool : curplatform .getToolsDependencies ()) {
195
- if (writer != null ) {
196
- writer .println ("runtime.tools." + tool .getName () + ".path=" + tool .getTool ().getInstallPath ());//$NON-NLS-1$ //$NON-NLS-2$
197
- writer .println ("runtime.tools." + tool .getName () + tool .getVersion () + ".path=" //$NON-NLS-1$ //$NON-NLS-2$
198
- + tool .getTool ().getInstallPath ());
199
- }
200
- }
201
- }
202
- } catch (FileNotFoundException | UnsupportedEncodingException e ) {
203
- return new Status (IStatus .WARNING , Activator .getId (), Messages .ArduinoManager_unable_to_create_file
204
- + pluginFile + '\n' + platform .getName () + Messages .ArduinoManager_will_not_work , e );
205
- }
206
-
207
- return Status .OK_STATUS ;
208
-
209
- }
210
-
211
174
static public void loadIndices (boolean immediatly ) {
212
175
if (immediatly ) {
213
176
internalLoadIndices ();
@@ -287,8 +250,7 @@ static public LibraryIndex getLibraryIndex() {
287
250
return libraryIndex ;
288
251
}
289
252
290
- static public Board getBoard (String boardName , String platformName , String packageName )
291
- throws CoreException {
253
+ static public Board getBoard (String boardName , String platformName , String packageName ) throws CoreException {
292
254
for (PackageIndex index : packageIndices ) {
293
255
Package pkg = index .getPackage (packageName );
294
256
if (pkg != null ) {
@@ -326,6 +288,21 @@ public static List<ArduinoPlatform> getPlatforms() {
326
288
return platforms ;
327
289
}
328
290
291
+ public static ArduinoPlatform getPlatform (String PlatformTxt ) {
292
+ String searchString = new File (PlatformTxt ).toString ();
293
+ for (PackageIndex index : packageIndices ) {
294
+ for (Package pkg : index .getPackages ()) {
295
+ for (ArduinoPlatform curPlatform : pkg .getPlatforms ()) {
296
+ String curFile = curPlatform .getPlatformFile ().toString ();
297
+ if (searchString .equals (curFile )) {
298
+ return curPlatform ;
299
+ }
300
+ }
301
+ }
302
+ }
303
+ return null ;
304
+ }
305
+
329
306
static public List <Board > getInstalledBoards () throws CoreException {
330
307
List <Board > boards = new ArrayList <>();
331
308
for (PackageIndex index : packageIndices ) {
@@ -400,15 +377,15 @@ public static IStatus downloadAndInstall(String pURL, String pArchiveFileName, P
400
377
Files .copy (dl .openStream (), Paths .get (archivePath .toString ()), StandardCopyOption .REPLACE_EXISTING );
401
378
}
402
379
} catch (IOException e ) {
403
- return new Status (IStatus .ERROR , Activator .getId (), Messages .ArduinoManager_Failed_to_download + pURL , e );
380
+ return new Status (IStatus .ERROR , Activator .getId (), Messages .Manager_Failed_to_download + pURL , e );
404
381
}
405
382
return processArchive (pArchiveFileName , pInstallPath , pForceDownload , archiveFullFileName , pMonitor );
406
383
}
407
384
408
385
private static IStatus processArchive (String pArchiveFileName , Path pInstallPath , boolean pForceDownload ,
409
386
String pArchiveFullFileName , IProgressMonitor pMonitor ) {
410
387
// Create an ArchiveInputStream with the correct archiving algorithm
411
- String faileToExtractMessage = Messages .ArduinoManager_Failed_to_extract + pArchiveFullFileName ;
388
+ String faileToExtractMessage = Messages .Manager_Failed_to_extract + pArchiveFullFileName ;
412
389
if (pArchiveFileName .endsWith ("tar.bz2" )) { //$NON-NLS-1$
413
390
try (ArchiveInputStream inStream = new TarArchiveInputStream (
414
391
new BZip2CompressorInputStream (new FileInputStream (pArchiveFullFileName )))) {
@@ -436,7 +413,7 @@ private static IStatus processArchive(String pArchiveFileName, Path pInstallPath
436
413
return new Status (IStatus .ERROR , Activator .getId (), faileToExtractMessage , e );
437
414
}
438
415
} else {
439
- return new Status (IStatus .ERROR , Activator .getId (), Messages .ArduinoManager_Format_not_supported );
416
+ return new Status (IStatus .ERROR , Activator .getId (), Messages .Manager_Format_not_supported );
440
417
}
441
418
}
442
419
@@ -510,7 +487,7 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
510
487
while (localstripPath > 0 ) {
511
488
slash = name .indexOf ("/" , slash ); //$NON-NLS-1$
512
489
if (slash == -1 ) {
513
- throw new IOException (Messages .ArduinoManager_no_single_root_folder );
490
+ throw new IOException (Messages .Manager_no_single_root_folder );
514
491
}
515
492
slash ++;
516
493
localstripPath --;
@@ -520,8 +497,8 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
520
497
521
498
// Strip the common path prefix when requested
522
499
if (!name .startsWith (pathPrefix )) {
523
- throw new IOException (Messages .ArduinoManager_no_single_root_folder_while_file + name
524
- + Messages .ArduinoManager_is_outside + pathPrefix );
500
+ throw new IOException (Messages .Manager_no_single_root_folder_while_file + name
501
+ + Messages .Manager_is_outside + pathPrefix );
525
502
}
526
503
name = name .substring (pathPrefix .length ());
527
504
if (name .isEmpty ()) {
@@ -532,8 +509,8 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
532
509
File outputLinkedFile = null ;
533
510
if (isLink && linkName != null ) {
534
511
if (!linkName .startsWith (pathPrefix )) {
535
- throw new IOException (Messages .ArduinoManager_no_single_root_folder_while_file + linkName
536
- + Messages .ArduinoManager_is_outside + pathPrefix );
512
+ throw new IOException (Messages .Manager_no_single_root_folder_while_file + linkName
513
+ + Messages .Manager_is_outside + pathPrefix );
537
514
}
538
515
linkName = linkName .substring (pathPrefix .length ());
539
516
outputLinkedFile = new File (destFolder , linkName );
@@ -542,32 +519,32 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
542
519
// Symbolic links are referenced with relative paths
543
520
outputLinkedFile = new File (linkName );
544
521
if (outputLinkedFile .isAbsolute ()) {
545
- System .err .println (Messages .ArduinoManager_Warning_file + outputFile
546
- + Messages .ArduinoManager_links_to_absolute_path + outputLinkedFile );
522
+ System .err .println (Messages .Manager_Warning_file + outputFile
523
+ + Messages .Manager_links_to_absolute_path + outputLinkedFile );
547
524
System .err .println ();
548
525
}
549
526
}
550
527
551
528
// Safety check
552
529
if (isDirectory ) {
553
530
if (outputFile .isFile () && !overwrite ) {
554
- throw new IOException (Messages . ArduinoManager_Cant_create_folder + outputFile
555
- + Messages .ArduinoManager_File_exists );
531
+ throw new IOException (
532
+ Messages . Manager_Cant_create_folder + outputFile + Messages .Manager_File_exists );
556
533
}
557
534
} else {
558
535
// - isLink
559
536
// - isSymLink
560
537
// - anything else
561
538
if (outputFile .exists () && !overwrite ) {
562
- throw new IOException (Messages . ArduinoManager_Cant_extract_file + outputFile
563
- + Messages .ArduinoManager_File_already_exists );
539
+ throw new IOException (
540
+ Messages . Manager_Cant_extract_file + outputFile + Messages .Manager_File_already_exists );
564
541
}
565
542
}
566
543
567
544
// Extract the entry
568
545
if (isDirectory ) {
569
546
if (!outputFile .exists () && !outputFile .mkdirs ()) {
570
- throw new IOException (Messages .ArduinoManager_Cant_create_folder + outputFile );
547
+ throw new IOException (Messages .Manager_Cant_create_folder + outputFile );
571
548
}
572
549
foldersTimestamps .put (outputFile , modifiedTime );
573
550
} else if (isLink ) {
@@ -670,7 +647,7 @@ private static void copyStreamToFile(InputStream in, long size, File outputFile)
670
647
while (leftToWrite > 0 ) {
671
648
int length = in .read (buffer );
672
649
if (length <= 0 ) {
673
- throw new IOException (Messages .ArduinoManager_Failed_to_extract + outputFile .getAbsolutePath ());
650
+ throw new IOException (Messages .Manager_Failed_to_extract + outputFile .getAbsolutePath ());
674
651
}
675
652
fos .write (buffer , 0 , length );
676
653
leftToWrite -= length ;
0 commit comments