package org.simantics.scl.osgi.internal;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
}
}
}
-
- private Path getPath() throws IOException {
- try {
- return Paths.get(FileLocator.toFileURL(url).toURI());
- } catch (URISyntaxException e) {
- throw new IOException(e);
+
+ /*
+ * This code is a copy from org.simantics.utils.ui.BundleUtils
+ */
+ public static File resolveWritableBundleFile(URL url) throws IOException {
+ // This returns file, jar, http etc. - essentially resolves the bundle protocol
+ URL resolved = FileLocator.resolve(url);
+ if (resolved.getProtocol().equals("file")) {
+ return new File(resolved.getPath());
}
+ return null;
}
-
+
+ private Path getPath() throws IOException {
+ File file = resolveWritableBundleFile(url);
+ return file != null ? file.toPath() : null;
+ }
+
@Override
public boolean isUpdateable() {
try {