Lines 11-23
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.update.internal.core; |
12 |
package org.eclipse.update.internal.core; |
13 |
|
13 |
|
|
|
14 |
import java.io.BufferedInputStream; |
15 |
import java.io.BufferedOutputStream; |
14 |
import java.io.File; |
16 |
import java.io.File; |
15 |
import java.io.FileInputStream; |
17 |
import java.io.FileInputStream; |
16 |
import java.io.FileOutputStream; |
18 |
import java.io.FileOutputStream; |
17 |
import java.io.IOException; |
19 |
import java.io.IOException; |
18 |
import java.io.InputStream; |
20 |
import java.io.InputStream; |
19 |
import java.net.URI; |
21 |
import java.io.OutputStream; |
20 |
import java.net.URISyntaxException; |
22 |
import java.net.MalformedURLException; |
|
|
23 |
import java.net.URL; |
21 |
import java.util.Date; |
24 |
import java.util.Date; |
22 |
import java.util.Enumeration; |
25 |
import java.util.Enumeration; |
23 |
import java.util.jar.JarFile; |
26 |
import java.util.jar.JarFile; |
Lines 48-74
Link Here
|
48 |
|
51 |
|
49 |
ContentReference[] oldReferences = oldFeature.getFeatureContentProvider().getPluginEntryContentReferences(oldPlugin, null); |
52 |
ContentReference[] oldReferences = oldFeature.getFeatureContentProvider().getPluginEntryContentReferences(oldPlugin, null); |
50 |
ContentReference[] newReferences = feature.getFeatureContentProvider().getPluginEntryContentReferences(newPlugin, null); |
53 |
ContentReference[] newReferences = feature.getFeatureContentProvider().getPluginEntryContentReferences(newPlugin, null); |
51 |
|
54 |
|
52 |
URI oldURI = null; |
55 |
URL oldURI = null; |
53 |
try { |
56 |
try { |
54 |
oldURI = new URI(consumer.getFeature().getSite().getURL().getPath() + |
57 |
oldURI = new URL(consumer.getFeature().getSite().getURL().getPath() + |
55 |
Site.DEFAULT_PLUGIN_PATH + |
58 |
Site.DEFAULT_PLUGIN_PATH + |
56 |
oldPlugin.getVersionedIdentifier().toString()); |
59 |
oldPlugin.getVersionedIdentifier().toString()); |
57 |
} catch (URISyntaxException e) { |
60 |
} catch (MalformedURLException e) { |
58 |
throw new IOException(e.getMessage()); |
61 |
throw new IOException(e.getMessage()); |
59 |
} |
62 |
} |
60 |
File oldJarFile = new File(oldURI); |
63 |
File oldJarFile = new File(oldURI.toExternalForm()); |
61 |
JarFile oldJar = new JarFile(oldJarFile); |
64 |
JarFile oldJar = new JarFile(oldJarFile); |
62 |
|
65 |
|
63 |
URI newURI = null; |
66 |
URL newURI = null; |
64 |
try { |
67 |
try { |
65 |
newURI = new URI(consumer.getFeature().getSite().getURL().getPath() + |
68 |
newURI = new URL(consumer.getFeature().getSite().getURL().getPath() + |
66 |
Site.DEFAULT_PLUGIN_PATH + |
69 |
Site.DEFAULT_PLUGIN_PATH + |
67 |
newPlugin.getVersionedIdentifier().toString()); |
70 |
newPlugin.getVersionedIdentifier().toString()); |
68 |
} catch (URISyntaxException e) { |
71 |
} catch (MalformedURLException e) { |
69 |
throw new IOException(e.getMessage()); |
72 |
throw new IOException(e.getMessage()); |
70 |
} |
73 |
} |
71 |
File newJarFile = new File(newURI); |
74 |
File newJarFile = new File(newURI.toExternalForm()); |
72 |
JarFile newJar = new JarFile(newJarFile); |
75 |
JarFile newJar = new JarFile(newJarFile); |
73 |
|
76 |
|
74 |
String tempFileName = oldURI + "-" + (new Date()).getTime(); //$NON-NLS-1$ |
77 |
String tempFileName = oldURI + "-" + (new Date()).getTime(); //$NON-NLS-1$ |
Lines 85-91
Link Here
|
85 |
newJar.close(); |
88 |
newJar.close(); |
86 |
oldJar.close(); |
89 |
oldJar.close(); |
87 |
|
90 |
|
88 |
newJarFile = new File(newURI); |
91 |
newJarFile = new File(newURI.toExternalForm()); |
89 |
newJarFile.delete(); |
92 |
newJarFile.delete(); |
90 |
|
93 |
|
91 |
newJarFile.createNewFile(); |
94 |
newJarFile.createNewFile(); |
Lines 93-117
Link Here
|
93 |
copyFile(tempFile, newJarFile); |
96 |
copyFile(tempFile, newJarFile); |
94 |
} |
97 |
} |
95 |
|
98 |
|
96 |
static boolean useNioCopy = true; |
|
|
97 |
public static void copyFile(File src, File dst) throws IOException { |
99 |
public static void copyFile(File src, File dst) throws IOException { |
98 |
if (useNioCopy) { |
100 |
InputStream in=null; |
99 |
try { |
101 |
OutputStream out=null; |
100 |
NioHelper.copyFile(src, dst); |
|
|
101 |
return; |
102 |
} catch (NoSuchMethodError e) { |
103 |
// fall through |
104 |
} catch (NoClassDefFoundError e) { |
105 |
// fall through |
106 |
} |
107 |
useNioCopy = false; |
108 |
} |
109 |
|
110 |
FileInputStream in=null; |
111 |
FileOutputStream out=null; |
112 |
try { |
102 |
try { |
113 |
in = new FileInputStream(src); |
103 |
in = new BufferedInputStream(new FileInputStream(src)); |
114 |
out = new FileOutputStream(dst); |
104 |
out = new BufferedOutputStream(new FileOutputStream(dst)); |
115 |
byte[] buffer = new byte[4096]; |
105 |
byte[] buffer = new byte[4096]; |
116 |
int len; |
106 |
int len; |
117 |
while ((len=in.read(buffer)) != -1) { |
107 |
while ((len=in.read(buffer)) != -1) { |
Lines 119-127
Link Here
|
119 |
} |
109 |
} |
120 |
} finally { |
110 |
} finally { |
121 |
if (in != null) |
111 |
if (in != null) |
122 |
in.close(); |
112 |
try { |
|
|
113 |
in.close(); |
114 |
} catch (IOException e) { |
115 |
} |
123 |
if (out != null) |
116 |
if (out != null) |
124 |
out.close(); |
117 |
try { |
|
|
118 |
out.close(); |
119 |
} catch (IOException e) { |
120 |
} |
125 |
} |
121 |
} |
126 |
} |
122 |
} |
127 |
|
123 |
|