public URL getURL() throws IOException { if (resource != null) { return resource; } else { String absolutePath = path.getAbsolutePath(); try { return new URI("file", absolutePath, null).toURL(); } catch(URISyntaxException e) { try { // Let's try this one more time. For some reason [ and ] // are not getting escaped in URI (I think they are for // ipv6 host stuff). We make this double attempt so that // we are not constantly trying to string substitute every // path we encounter. return new URI("file", escapeReservedChars(absolutePath), null).toURL(); } catch (URISyntaxException ee) { throw new IOException(ee.getMessage()); } } } }
if (!resource.getURL().getProtocol().equals("jar")) { file = resource.getAbsolutePath(); } else { InputStream is = resource.getInputStream(); FileOutputStream os = null; File dstFile = new File(System.getProperty("java.io.tmpdir") + File.pathSeparator + resource.getName()); if (!dstFile.exists()) { // File doesn't exist yet. Extract it. try { throw runtime.newLoadError("Error loading file -- " + resource.getName()); } finally { try {
public void load(Ruby runtime, boolean wrap) { try { IRScope script = CompiledScriptLoader.loadScriptFromFile(runtime, resource.getInputStream(), resource.getPath(), resource.getName(), resource.isAbsolute()); if (script == null) { // we're depending on the side effect of the load, which loads the class but does not turn it into a script // I don't like it, but until we restructure the code a bit more, we'll need to quietly let it by here. return; } script.setFileName(resource.getName()); runtime.loadScope(script, wrap); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
public void load(Ruby runtime, boolean wrap) { try { Script script = CompiledScriptLoader.loadScriptFromFile(runtime, resource.getInputStream(), resource.getName()); if (script == null) { // we're depending on the side effect of the load, which loads the class but does not turn it into a script // I don't like it, but until we restructure the code a bit more, we'll need to quietly let it by here. return; } script.setFilename(resource.getName()); runtime.loadScript(script, wrap); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
LoadServiceResource foundResource = new LoadServiceResource(loc, path); debugLogFound(foundResource); return foundResource;
public String getAbsolutePath() { if (absolutePath != null) return absolutePath; try { return absolutePath = new File(URLUtil.getPath(getURL())).getCanonicalPath(); } catch (IOException e) { return absolutePath = resource.toString(); } }
@Override public String toString() { return "ExternalScript: " + resource.getName(); } }
@Override protected String resolveLoadName(LoadServiceResource foundResource, String previousPath) { String path = foundResource.getAbsolutePath(); if (Platform.IS_WINDOWS) { path = path.replace('\\', '/'); } return path; }
LoadServiceResource foundResource = new LoadServiceResource(loc, path); debugLogFound(foundResource); return foundResource;
@Deprecated protected final void debugLogFound( LoadServiceResource resource ) { if (RubyInstanceConfig.DEBUG_LOAD_SERVICE) { String resourceUrl; try { resourceUrl = resource.getURL().toString(); } catch (IOException e) { resourceUrl = e.getMessage(); } LOG.info( "found: {}", resourceUrl ); } }
@Override public String toString() { return "ExternalScript: " + resource.getName(); } }
@Override protected String resolveLoadName(LoadServiceResource foundResource, String previousPath) { String path = foundResource.getAbsolutePath(); if (Platform.IS_WINDOWS) { path = path.replace('\\', '/'); } return path; }
public void load(Ruby runtime, boolean wrap) { try { Script script = CompiledScriptLoader.loadScriptFromFile(runtime, resource.getInputStream(), resource.getName()); if (script == null) { // we're depending on the side effect of the load, which loads the class but does not turn it into a script // I don't like it, but until we restructure the code a bit more, we'll need to quietly let it by here. return; } script.setFilename(resource.getName()); runtime.loadScript(script, wrap); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
public void load(Ruby runtime, boolean wrap) { try { IRScope script = CompiledScriptLoader.loadScriptFromFile(runtime, resource.getInputStream(), resource.getPath(), resource.getName(), resource.isAbsolute()); if (script == null) { // we're depending on the side effect of the load, which loads the class but does not turn it into a script // I don't like it, but until we restructure the code a bit more, we'll need to quietly let it by here. return; } script.setFileName(resource.getName()); runtime.loadScope(script, wrap); } catch (IOException e) { throw runtime.newIOErrorFromException(e); } } }
URL url = bundle.getEntry(sb.toString()); if (url != null) { return new LoadServiceResource( OSGiFileLocator.getLocalURL(url), name);
if (!resource.getURL().getProtocol().equals("jar")) { file = resource.getAbsolutePath(); } else { InputStream is = resource.getInputStream(); FileOutputStream os = null; File dstFile = new File(System.getProperty("java.io.tmpdir") + File.pathSeparator + resource.getName()); if (!dstFile.exists()) { // File doesn't exist yet. Extract it. try { throw runtime.newLoadError("Error loading file -- " + resource.getName()); } finally { try {
protected void debugLogFound( LoadServiceResource resource ) { if (RubyInstanceConfig.DEBUG_LOAD_SERVICE) { String resourceUrl; try { resourceUrl = resource.getURL().toString(); } catch (IOException e) { resourceUrl = e.getMessage(); } LOG.info( "found: " + resourceUrl ); } }
@Override public String toString() { return "ExternalScript: " + resource.getName(); } }
@Override protected String resolveLoadName(LoadServiceResource foundResource, String previousPath) { String path = foundResource.getAbsolutePath(); if (Platform.IS_WINDOWS) { path = path.replace('\\', '/'); } return path; }
public URL getURL() throws IOException { if (resource != null) { return resource; } else { String absolutePath = path.getAbsolutePath(); try { return new URI("file", absolutePath, null).toURL(); } catch(URISyntaxException e) { try { // Let's try this one more time. For some reason [ and ] // are not getting escaped in URI (I think they are for // ipv6 host stuff). We make this double attempt so that // we are not constantly trying to string substitute every // path we encounter. return new URI("file", escapeReservedChars(absolutePath), null).toURL(); } catch (URISyntaxException ee) { throw new IOException(ee.getMessage()); } } } }