8000 Fix https://github.com/angelozerr/typescript.java/issues/222 · angelozerr/typescript.java@a97b599 · GitHub
[go: up one dir, main page]

Skip to content

Commit a97b599

Browse files
committed
Fix #222
1 parent 9a2fe98 commit a97b599

File tree

24 files changed

+86
-44
lines changed

24 files changed

+86
-44
lines changed

core/ts.core/META-INF/MANIFEST.MF

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ Export-Package: ts,
3838
ts.resources,
3939
ts.resources.jsonconfig,
4040
ts.utils
41-
Require-Bundle: com.google.gson;bundle-version="2.1.0"
41+
Require-Bundle: com.google.gson;bundle-version="2.1.0",
42+
org.tukaani.xz;resolution:=optional
43+

core/ts.core/src/ts/utils/ZipUtils.java

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.zip.ZipEntry;
2323
import java.util.zip.ZipInputStream;
2424

25+
import org.tukaani.xz.XZInputStream;
26+
2527
import ts.internal.io.tar.TarEntry;
2628
import ts.internal.io.tar.TarException;
2729
import ts.internal.io.tar.TarInputStream;
@@ -34,6 +36,7 @@ public class ZipUtils {
3436

3537
public static final String ZIP_EXTENSION = ".zip";
3638
public static final String TAR_GZ_EXTENSION = ".tar.gz";
39+
public static final String TAR_XZ_EXTENSION = ".tar.xz";
3740
private static final String BIN_FOLDER = "/bin";
3841

3942
private ZipUtils() {
@@ -50,15 +53,25 @@ public static boolean isZipFile(File file) {
5053
}
5154

5255
/**
53-
* Returns true if the given file is a zip file and false otherwise.
56+
* Returns true if the given file is a tar.gz file and false otherwise.
5457
*
5558
* @param file
56-
* @return true if the given file is a zip file and false otherwise.
59+
* @return true if the given file is a tar.gz file and false otherwise.
5760
*/
58-
public static boolean isTarFile(File file) {
61+
public static boolean isTarGZFile(File file) {
5962
return file.isFile() && file.getName().toLowerCase().endsWith(TAR_GZ_EXTENSION);
6063
}
6164

65+
/**
66+
* Returns true if the given file is a tar.xz file and false otherwise.
67+
*
68+
* @param file
69+
* @return true if the given file is a tar.xz file and false otherwise.
70+
*/
71+
public static boolean isTarXZFile(File file) {
72+
return file.isFile() && file.getName().toLowerCase().endsWith(TAR_XZ_EXTENSION);
73+
}
74+
6275
/**
6376
* Extract zip file to destination folder.
6477
*
@@ -129,12 +142,37 @@ public static void extractZip(File file, File destination) throws IOException {
129142
* @param destination
130143
* destination folder
131144
*/
132-
public static void extractTar(File file, File destination) throws IOException {
145+
public static void extractTarGZ(File file, File destination) throws IOException {
146+
extractTar(file, destination, true);
147+
}
148+
149+
/**
150+
* Extract tar.xz file to destination folder.
151+
*
152+
* @param file
153+
* zip file to extract
154+
* @param destination
155+
* destination folder
156+
*/
157+
public static void extractTarXZ(File file, File destination) throws IOException {
158+
extractTar(file, destination, false);
159+
}
160+
161+
/**
162+
* Extract tar.gz/tar.xz file to destination folder.
163+
*
164+
* @param file
165+
* zip file to extract
166+
* @param destination
167+
* destination folder
168+
*/
169+
private static void extractTar(File file, File destination, boolean tarGz) throws IOException {
133170
TarInputStream in = null;
134171
OutputStream out = null;
135172
try {
136173
// Open the ZIP file
137-
in = new TarInputStream(new GZIPInputStream(new FileInputStream(file)));
174+
in = new TarInputStream(tarGz ? new GZIPInputStream(new FileInputStream(file))
175+
: new XZInputStream(new FileInputStream(file)));
138176

139177
// Get the first entry
140178
TarEntry entry = null;
@@ -171,11 +209,11 @@ public static void extractTar(File file, File destination) throws IOException {
171209
out.close();
172210
// Preserve original modification date
173211
extractedFile.setLastModified(entry.getTime());
174-
long mode = entry.getMode();
175-
if ((mode & 00100) > 0) {
176-
// Preserve execute permissions
177-
extractedFile.setExecutable(true, (mode & 00001) == 0);
178-
}
212+
long mode = entry.getMode();
213+
if ((mode & 00100) > 0) {
214+
// Preserve execute permissions
215+
extractedFile.setExecutable(true, (mode & 00001) == 0);
216+
}
179217
break;
180218
case TarEntry.LINK:
181219
File linkFile = new File(destination, outFilename);

eclipse/embed/ts.eclipse.ide.serv 10000 er.nodejs.embed.linux.gtk.x86/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ bin.includes = META-INF/,\
44
.,\
55
plugin.properties,\
66
plugin.xml,\
7-
node-v6.9.4-linux-x86.tar.gz
7+
node-v8.9.1-linux-x86.tar.xz

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.linux.gtk.x86/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
pluginName=Embed Node.js - gtk.linux.x86
1212
providerName=Angelo ZERR
1313

14-
nodeJSInstall_v6.9.4.name=node-v6.9.4-linux-x86
14+
nodeJSInstall.name=node-v8.9.1-linux-x86

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.linux.gtk.x86/plugin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
<extension point="ts.eclipse.ide.core.nodeJSInstalls" >
2121
<install
22-
id="node-v6.9.4"
23-
name="%nodeJSInstall_v6.9.4.name"
24-
path="/node-v6.9.4-linux-x86/bin/node"
25-
zip="/node-v6.9.4-linux-x86.tar.gz"/>
22+
id="node-v8.9.1"
23+
name="%nodeJSInstall.name"
24+
path="/node-v8.9.1-linux-x86/bin/node"
25+
zip="/node-v8.9.1-linux-x86.tar.xz"/>
2626
</extension>
2727

2828
</plugin>

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.linux.gtk.x86_64/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ bin.includes = META-INF/,\
44
.,\
55
plugin.properties,\
66
plugin.xml,\
7-
node-v6.9.4-linux-x64.tar.gz
7+
node-v8.9.1-linux-x64.tar.xz

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.linux.gtk.x86_64/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
pluginName=Embed Node.js - linux.gtk.x86_64
1212
providerName=Angelo ZERR
1313

14-
nodeJSInstall_v6.9.4.name=node-v6.9.4-linux-x64
14+
nodeJSInstall.name=node-v8.9.1-linux-x64

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.linux.gtk.x86_64/plugin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
<extension point="ts.eclipse.ide.core.nodeJSInstalls" >
2020
<install
21-
id="node-v6.9.4"
22-
name="%nodeJSInstall_v6.9.4.name"
23-
path="/node-v6.9.4-linux-x64/bin/node"
24-
zip="/node-v6.9.4-linux-x64.tar.gz"/>
21+
id="node-v8.9.1"
22+
name="%nodeJSInstall_v8.9.1.name"
23+
path="/node-v8.9.1-linux-x64/bin/node"
24+
zip="/node-v8.9.1-linux-x64.tar.xz"/>
2525
</extension>
2626

2727
</plugin>

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.macosx.cocoa.x86_64/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ bin.includes = META-INF/,\
44
.,\
55
plugin.properties,\
66
plugin.xml,\
7-
node-v6.9.4-darwin-x64.tar.gz
7+
node-v8.9.1-darwin-x64.tar.gz
88

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.macosx.cocoa.x86_64/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
pluginName=Embed Node.js - macosx.cocoa.x86_64
1212
providerName=Angelo ZERR
1313

14-
nodeJSInstall_v6.9.4.name=node-v6.9.4-darwin-x64
14+
nodeJSInstall.name=node-v8.9.1-darwin-x64

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.macosx.cocoa.x86_64/plugin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
<extension point="ts.eclipse.ide.core.nodeJSInstalls" >
1818
<install
19-
id="node-v6.9.4"
20-
name="%nodeJSInstall_v6.9.4.name"
21-
path="/node-v6.9.4-darwin-x64/bin/node"
22-
zip="/node-v6.9.4-darwin-x64.tar.gz"/>
19+
id="node-v8.9.1"
20+
name="%nodeJSInstall.name"
21+
path="/node-v8.9.1-darwin-x64/bin/node"
22+
zip="/node-v8.9.1-darwin-x64.tar.gz"/>
2323
</extension>
2424

2525
</plugin>

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ bin.includes = META-INF/,\
44
.,\
55
plugin.properties,\
66
plugin.xml,\
7-
node-v6.9.4-win-x86.zip
7+
node-v8.9.1-win-x86.zip
88

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
pluginName=Embed Node.js - win32.win32.x86
1212
providerName=Angelo ZERR
1313

14-
nodeJSInstall_v6.9.4.name=node-v6.9.4-win-x86
14+
nodeJSInstall.name=node-v8.9.1-win-x86

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86/plugin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
<extension point="ts.eclipse.ide.core.nodeJSInstalls" >
1818
<install
19-
id="node-v6.9.4"
20-
name="%nodeJSInstall_v6.9.4.name"
21-
path="/node-v6.9.4-win-x86/node.exe"
22-
zip="/node-v6.9.4-win-x86.zip" />
19+
id="node-v8.9.1"
20+
name="%nodeJSInstall.name"
21+
path="/node-v8.9.1-win-x86/node.exe"
22+
zip="/node-v8.9.1-win-x86.zip" />
2323
</extension>
2424

2525
</plugin>

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86_64/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ bin.includes = META-INF/,\
44
.,\
55
plugin.properties,\
66
plugin.xml,\
7-
node-v6.9.4-win-x64.zip
7+
node-v8.9.1-win-x64.zip
88

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86_64/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
pluginName=Embed Node.js - win32.x86_64
1212
providerName=Angelo ZERR
1313

14-
nodeJSInstall_v6.9.4.name=node-v6.9.4-win-x64
14+
nodeJSInstall.name=node-v8.9.1-win-x64

eclipse/embed/ts.eclipse.ide.server.nodejs.embed.win32.win32.x86_64/plugin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
<extension point="ts.eclipse.ide.core.nodeJSInstalls" >
1818
<install
19-
id="node-v6.9.4"
20-
name="%nodeJSInstall_v6.9.4.name"
21-
path="/node-v6.9.4-win-x64/node.exe"
22-
zip="/node-v6.9.4-win-x64.zip" />
19+
id="node-v8.9.1"
20+
name="%nodeJSInstall.name"
21+
path="/node-v8.9.1-win-x64/node.exe"
22+
zip="/node-v8.9.1-win-x64.zip" />
2323
</extension>
2424

2525
</plugin>

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/internal/core/nodejs/NodejsInstall.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ private void createClass(IConfigurationElement element) throws IOException {
8181
if (zipFile.exists()) {
8282
if (ZipUtils.isZipFile(zipFile)) {
8383
ZipUtils.extractZip(zipFile, < BBF0 span class=pl-s1>baseDir);
84-
} else if (ZipUtils.isTarFile(zipFile)) {
85-
ZipUtils.extractTar(zipFile, baseDir);
84+
} else if (ZipUtils.isTarGZFile(zipFile)) {
85+
ZipUtils.extractTarGZ(zipFile, baseDir);
86+
} else if (ZipUtils.isTarXZFile(zipFile)) {
87+
ZipUtils.extractTarXZ(zipFile, baseDir);
8688
}
8789

8890
if(this.path.exists()) {

eclipse/ts.eclipse.ide.core/src/ts/eclipse/ide/internal/core/repository/IDETypeScriptRepositoryManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private static File computeActualBaseDir(IConfigurationElement ce) throws IOExce
224224
} else {
225225
zipFile = new File(bundleDir, baseDir + ZipUtils.TAR_GZ_EXTENSION);
226226
if (zipFile.exists()) {
227-
ZipUtils.extractTar(zipFile, dir);
227+
ZipUtils.extractTarGZ(zipFile, dir);
228228
return dir;
229229
}
230230
}

0 commit comments

Comments
 (0)
0