Skip to content

Commit e1ced0b

Browse files
author
jan
committed
Add code and needed packages
1 parent b1b8e70 commit e1ced0b

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

io.sloeber.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.cdt.managedbuilder.core,
2222
org.eclipse.debug.core,
2323
org.eclipse.core.variables,
2424
org.apache.commons.commons-io,
25-
org.apache.commons.commons-compress
25+
org.apache.commons.commons-compress,
26+
com.github.luben.zstd-jni;bundle-version="1.5.5"
2627
Export-Package: cc.arduino.packages;x-internal:=true,
2728
cc.arduino.packages.discoverers;x-internal:=true,
2829
cc.arduino.packages.ssh;x-internal:=true,

io.sloeber.core/src/io/sloeber/core/tools/PackageManager.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
2222
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
2323
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
24+
import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream;
2425
import org.apache.commons.io.FileUtils;
2526
import org.eclipse.core.runtime.IPath;
2627
import org.eclipse.core.runtime.IProgressMonitor;
@@ -79,27 +80,34 @@ private static IStatus processArchive(String pArchiveFileName, IPath pInstallPat
7980
// Create an ArchiveInputStream with the correct archiving algorithm
8081
String faileToExtractMessage = Messages.Manager_Failed_to_extract.replace(FILE, pArchiveFullFileName);
8182
if (pArchiveFileName.endsWith("tar.bz2")) { //$NON-NLS-1$
82-
try (ArchiveInputStream inStream = new TarArchiveInputStream(
83+
try (TarArchiveInputStream inStream = new TarArchiveInputStream(
8384
new BZip2CompressorInputStream(new FileInputStream(pArchiveFullFileName)))) {
8485
return extract(inStream, pInstallPath.toFile(), 1, pForceDownload, pMonitor);
8586
} catch (IOException | InterruptedException e) {
8687
return new Status(IStatus.ERROR, Activator.getId(), faileToExtractMessage, e);
8788
}
8889
} else if (pArchiveFileName.endsWith("zip")) { //$NON-NLS-1$
89-
try (ArchiveInputStream in = new ZipArchiveInputStream(new FileInputStream(pArchiveFullFileName))) {
90+
try (ZipArchiveInputStream in = new ZipArchiveInputStream(new FileInputStream(pArchiveFullFileName))) {
9091
return extract(in, pInstallPath.toFile(), 1, pForceDownload, pMonitor);
9192
} catch (IOException | InterruptedException e) {
9293
return new Status(IStatus.ERROR, Activator.getId(), faileToExtractMessage, e);
9394
}
9495
} else if (pArchiveFileName.endsWith("tar.gz")) { //$NON-NLS-1$
95-
try (ArchiveInputStream in = new TarArchiveInputStream(
96+
try (TarArchiveInputStream in = new TarArchiveInputStream(
9697
new GzipCompressorInputStream(new FileInputStream(pArchiveFullFileName)))) {
9798
return extract(in, pInstallPath.toFile(), 1, pForceDownload, pMonitor);
9899
} catch (IOException | InterruptedException e) {
99100
return new Status(IStatus.ERROR, Activator.getId(), faileToExtractMessage, e);
100101
}
102+
} else if (pArchiveFileName.endsWith("tar.zst")) { //$NON-NLS-1$
103+
try (TarArchiveInputStream in = new TarArchiveInputStream(
104+
new ZstdCompressorInputStream(new FileInputStream(pArchiveFullFileName)))) {
105+
return extract(in, pInstallPath.toFile(), 1, pForceDownload, pMonitor);
106+
} catch (IOException | InterruptedException e) {
107+
return new Status(IStatus.ERROR, Activator.getId(), faileToExtractMessage, e);
108+
}
101109
} else if (pArchiveFileName.endsWith("tar")) { //$NON-NLS-1$
102-
try (ArchiveInputStream in = new TarArchiveInputStream(new FileInputStream(pArchiveFullFileName))) {
110+
try (TarArchiveInputStream in = new TarArchiveInputStream(new FileInputStream(pArchiveFullFileName))) {
103111
return extract(in, pInstallPath.toFile(), 1, pForceDownload, pMonitor);
104112
} catch (IOException | InterruptedException e) {
105113
return new Status(IStatus.ERROR, Activator.getId(), faileToExtractMessage, e);
@@ -109,7 +117,7 @@ private static IStatus processArchive(String pArchiveFileName, IPath pInstallPat
109117
}
110118
}
111119

112-
private static IStatus extract(ArchiveInputStream in, File destFolder, int stripPath, boolean overwrite,
120+
private static IStatus extract(ArchiveInputStream<?> in, File destFolder, int stripPath, boolean overwrite,
113121
IProgressMonitor pMonitor) throws IOException, InterruptedException {
114122

115123
// Folders timestamps must be set at the end of archive extraction

io.sloeber.product/sloeber.target

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
</location>
3333
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="DirectFromMaven" missingManifest="error" type="Maven">
3434
<dependencies>
35+
<dependency>
36+
<groupId>com.github.luben</groupId>
37+
<artifactId>zstd-jni</artifactId>
38+
<version>1.5.5-11</version>
39+
<type>jar</type>
40+
</dependency>
3541
<dependency>
3642
<groupId>com.google.code.gson</groupId>
3743
<artifactId>gson</artifactId>

0 commit comments

Comments
 (0)