private byte[] getBytesFromArchive(SyspathArchive archive, String name) { String entryname = name.replace('.', SLASH_CHAR) + ".class"; ZipEntry ze = archive.getEntry(entryname); if (ze == null) { return null; } try { return getBytesFromInputStream(archive.getInputStream(ze), (int) ze.getSize()); } catch (IOException e) { return null; } }
@Override protected Enumeration<URL> findResources(String res) throws IOException { List<URL> resources = new ArrayList<URL>(); PySystemState sys = Py.getSystemState(); if (res.charAt(0) == SLASH_CHAR) { res = res.substring(1); } String entryRes = res; if (File.separatorChar != SLASH_CHAR) { res = res.replace(SLASH_CHAR, File.separatorChar); entryRes = entryRes.replace(File.separatorChar, SLASH_CHAR); } PyList path = sys.path; for (int i = 0; i < path.__len__(); i++) { PyObject entry = replacePathItem(sys, i, path); if (entry instanceof SyspathArchive) { SyspathArchive archive = (SyspathArchive) entry; ZipEntry ze = archive.getEntry(entryRes); if (ze != null) { try { resources.add(new URL("jar:file:" + archive.asUriCompatibleString() + "!/" + entryRes)); } catch (MalformedURLException e) { throw new RuntimeException(e); } } continue; } if (!(entry instanceof PyUnicode)) { entry = entry.__str__(); } String dir = sys.getPath(entry.toString()); try { File resource = new File(dir, res); if (!resource.exists()) { continue; } resources.add(resource.toURI().toURL()); } catch (MalformedURLException e) { throw new RuntimeException(e); } } return Collections.enumeration(resources); }