X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.ui%2Fsrc%2Forg%2Fsimantics%2Futils%2Fui%2FBundleUtils.java;h=62fd287c18f51458c0b6b4b79c6264601e87b8f0;hb=4f38bc070c3e1e40d02bd8da64cc93a798c9aace;hp=f3e3383f67cd8d5da36c519962e5084c9afa3570;hpb=ba85c75dd6893c597f4befa3d2c9f32bee2fc85d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/BundleUtils.java b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/BundleUtils.java index f3e3383f6..62fd287c1 100644 --- a/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/BundleUtils.java +++ b/bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/BundleUtils.java @@ -90,7 +90,7 @@ public final class BundleUtils { public static URL find(String bundleId, String path) { return find(Platform.getBundle(bundleId), path); } - + public static File findFile(String bundleId, String path) throws IOException { URL url = find(bundleId, path); if (url == null) @@ -98,5 +98,17 @@ public final class BundleUtils { url = FileLocator.toFileURL(url); return new File(url.getPath()); } - + + /** + * @since 1.31.0 + */ + 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; + } + }