Skip to content

Commit adadd00

Browse files
author
jantje
committed
#709 do not try to symlink on windows
Also some other changes are in this file
1 parent 05a879b commit adadd00

File tree

1 file changed

+46
-48
lines changed

1 file changed

+46
-48
lines changed

io.sloeber.core/src/io/sloeber/core/managers/Manager.java

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
4444
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
4545
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
46-
import org.eclipse.core.runtime.CoreException;
4746
import org.eclipse.core.runtime.IPath;
4847
import org.eclipse.core.runtime.IProgressMonitor;
4948
import org.eclipse.core.runtime.IStatus;
@@ -90,40 +89,36 @@ public static void addPackageURLs(HashSet<String> packageUrlsToAdd, boolean forc
9089
*/
9190
public static void startup_Pluging(IProgressMonitor monitor) {
9291
loadIndices(ConfigurationPreferences.getUpdateJasonFilesValue());
93-
try {
94-
List<Board> allBoards = getInstalledBoards();
95-
if (allBoards.isEmpty()) { // If boards are installed do nothing
96-
InstallDefaultLibraries(monitor);
97-
MyMultiStatus mstatus = new MyMultiStatus("Failed to configer Sloeber"); //$NON-NLS-1$
98-
99-
// Downmload sample programs
100-
mstatus.addErrors(downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE,
101-
Paths.get(ConfigurationPreferences.getInstallationPathExamples().toString()), false, monitor));
102-
103-
if (mstatus.isOK()) {
104-
// if successfully installed the examples: add the boards
105-
106-
Package pkg = packageIndices.get(0).getPackages().get(0);
107-
if (pkg != null) {
108-
ArduinoPlatform platform = pkg.getLatestPlatform(Defaults.PLATFORM_NAME);
109-
if (platform == null) {
110-
ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
111-
pkg.getLatestPlatforms().toArray(platformList);
112-
platform = platformList[0];
113-
}
114-
if (platform != null) {
115-
mstatus.addErrors(downloadAndInstall(platform, false, monitor));
116-
}
92+
List<Board> allBoards = getInstalledBoards();
93+
if (allBoards.isEmpty()) { // If boards are installed do nothing
94+
InstallDefaultLibraries(monitor);
95+
MyMultiStatus mstatus = new MyMultiStatus("Failed to configer Sloeber"); //$NON-NLS-1$
96+
97+
// Downnload sample programs
98+
mstatus.addErrors(downloadAndInstall(Defaults.EXAMPLES_URL, Defaults.EXAMPLE_PACKAGE,
99+
Paths.get(ConfigurationPreferences.getInstallationPathExamples().toString()), false, monitor));
100+
101+
if (mstatus.isOK()) {
102+
// if successfully installed the examples: add the boards
103+
104+
Package pkg = getPackageIndices().get(0).getPackages().get(0);
105+
if (pkg != null) {
106+
ArduinoPlatform platform = pkg.getLatestPlatform(Defaults.PLATFORM_NAME);
107+
if (platform == null) {
108+
ArduinoPlatform[] platformList = new ArduinoPlatform[pkg.getLatestPlatforms().size()];
109+
pkg.getLatestPlatforms().toArray(platformList);
110+
platform = platformList[0];
111+
}
112+
if (platform != null) {
113+
mstatus.addErrors(downloadAndInstall(platform, false, monitor));
117114
}
118115
}
119-
if (!mstatus.isOK()) {
120-
StatusManager stMan = StatusManager.getManager();
121-
stMan.handle(mstatus, StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK);
122-
}
123-
124116
}
125-
} catch (CoreException e) {
126-
e.printStackTrace();
117+
if (!mstatus.isOK()) {
118+
StatusManager stMan = StatusManager.getManager();
119+
stMan.handle(mstatus, StatusManager.LOG | StatusManager.SHOW | StatusManager.BLOCK);
120+
}
121+
127122
}
128123
myIsReady = true;
129124

@@ -294,8 +289,8 @@ static public LibraryIndex getLibraryIndex() {
294289
return libraryIndex;
295290
}
296291

297-
static public Board getBoard(String boardName, String platformName, String packageName) throws CoreException {
298-
for (PackageIndex index : packageIndices) {
292+
static public Board getBoard(String boardName, String platformName, String packageName) {
293+
for (PackageIndex index : getPackageIndices()) {
299294
Package pkg = index.getPackage(packageName);
300295
if (pkg != null) {
301296
ArduinoPlatform platform = pkg.getLatestPlatform(platformName);
@@ -310,9 +305,9 @@ static public Board getBoard(String boardName, String platformName, String packa
310305
return null;
311306
}
312307

313-
static public List<Board> getBoards() throws CoreException {
308+
static public List<Board> getBoards() {
314309
List<Board> boards = new ArrayList<>();
315-
for (PackageIndex index : packageIndices) {
310+
for (PackageIndex index : getPackageIndices()) {
316311
for (Package pkg : index.getPackages()) {
317312
for (ArduinoPlatform platform : pkg.getLatestPlatforms()) {
318313
boards.addAll(platform.getBoards());
@@ -324,7 +319,7 @@ static public List<Board> getBoards() throws CoreException {
324319

325320
public static List<ArduinoPlatform> getPlatforms() {
326321
List<ArduinoPlatform> platforms = new ArrayList<>();
327-
for (PackageIndex index : packageIndices) {
322+
for (PackageIndex index : getPackageIndices()) {
328323
for (Package pkg : index.getPackages()) {
329324
platforms.addAll(pkg.getPlatforms());
330325
}
@@ -334,7 +329,7 @@ public static List<ArduinoPlatform> getPlatforms() {
334329

335330
public static IPath getPlatformInstallPath(String vendor, String architecture) {
336331

337-
for (PackageIndex index : packageIndices) {
332+
for (PackageIndex index : getPackageIndices()) {
338333
for (Package pkg : index.getPackages()) {
339334
for (ArduinoPlatform curPlatform : pkg.getInstalledPlatforms()) {
340335
if (architecture.equalsIgnoreCase(curPlatform.getArchitecture())
@@ -354,7 +349,7 @@ public static IPath getPlatformInstallPath(String vendor, String architecture) {
354349
* @return the found platform otherwise null
355350
*/
356351
public static ArduinoPlatform getPlatform(File platformTxt) {
357-
for (PackageIndex index : packageIndices) {
352+
for (PackageIndex index : getPackageIndices()) {
358353
for (Package pkg : index.getPackages()) {
359354
for (ArduinoPlatform curPlatform : pkg.getPlatforms()) {
360355
if (curPlatform.getPlatformFile().equals(platformTxt)) {
@@ -368,7 +363,7 @@ public static ArduinoPlatform getPlatform(File platformTxt) {
368363

369364
static public List<ArduinoPlatform> getInstalledPlatforms() {
370365
List<ArduinoPlatform> platforms = new ArrayList<>();
371-
for (PackageIndex index : packageIndices) {
366+
for (PackageIndex index : getPackageIndices()) {
372367
for (Package pkg : index.getPackages()) {
373368

374369
platforms.addAll(pkg.getInstalledPlatforms());
@@ -378,9 +373,9 @@ static public List<ArduinoPlatform> getInstalledPlatforms() {
378373
return platforms;
379374
}
380375

381-
static public List<Board> getInstalledBoards() throws CoreException {
376+
static public List<Board> getInstalledBoards() {
382377
List<Board> boards = new ArrayList<>();
383-
for (PackageIndex index : packageIndices) {
378+
for (PackageIndex index : getPackageIndices()) {
384379
for (Package pkg : index.getPackages()) {
385380
for (ArduinoPlatform platform : pkg.getInstalledPlatforms()) {
386381
boards.addAll(platform.getBoards());
@@ -392,14 +387,14 @@ static public List<Board> getInstalledBoards() throws CoreException {
392387

393388
static public List<Package> getPackages() {
394389
List<Package> packages = new ArrayList<>();
395-
for (PackageIndex index : packageIndices) {
390+
for (PackageIndex index : getPackageIndices()) {
396391
packages.addAll(index.getPackages());
397392
}
398393
return packages;
399394
}
400395

401396
static public Package getPackage(String JasonName, String packageName) {
402-
for (PackageIndex index : packageIndices) {
397+
for (PackageIndex index : getPackageIndices()) {
403398
if (index.getJsonFileName().equals(JasonName)) {
404399
return index.getPackage(packageName);
405400
}
@@ -408,7 +403,7 @@ static public Package getPackage(String JasonName, String packageName) {
408403
}
409404

410405
static public Package getPackage(String packageName) {
411-
for (PackageIndex index : packageIndices) {
406+
for (PackageIndex index : getPackageIndices()) {
412407
Package pkg = index.getPackage(packageName);
413408
if (pkg != null) {
414409
return pkg;
@@ -418,7 +413,7 @@ static public Package getPackage(String packageName) {
418413
}
419414

420415
static public Tool getTool(String packageName, String toolName, String version) {
421-
for (PackageIndex index : packageIndices) {
416+
for (PackageIndex index : getPackageIndices()) {
422417
Package pkg = index.getPackage(packageName);
423418
if (pkg != null) {
424419
Tool tool = pkg.getTool(toolName, version);
@@ -666,7 +661,10 @@ public static IStatus extract(ArchiveInputStream in, File destFolder, int stripP
666661
if (entry.getKey().exists() && overwrite) {
667662
entry.getKey().delete();
668663
}
669-
symlink(entry.getValue(), entry.getKey());
664+
// do not make symlinks in windows
665+
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
666+
symlink(entry.getValue(), entry.getKey());
667+
}
670668
entry.getKey().setLastModified(symLinksModifiedTimes.get(entry.getKey()).longValue());
671669
}
672670

@@ -855,7 +853,7 @@ public static void setBoardsPackageURL(String[] newBoardJsonUrls) {
855853
loadIndices(false);
856854
}
857855

858-
public static String getBoardsPackageURLs() {
856+
public static String getDefaultBoardsPackageURLs() {
859857
return ConfigurationPreferences.getDefaultBoardsPackageURLs();
860858
}
861859

0 commit comments

Comments
 (0)