private static BundleFile getBundlFile(Class<?> clazz) throws BundleException { URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); File jarOrDirectory = new File(objUrl.getPath()); if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) { throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUrl, clazz.getName()), BundleException.READ_ERROR); } try { return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null); } catch (IOException e) { throw new BundleException(String.format("Cannot access bundle at '%s'.", jarOrDirectory), BundleException.READ_ERROR, e); } }
/** * Constructs a DirBundleFile * @param basefile the base file * @throws IOException */ public DirBundleFile(File basefile, boolean enableStrictBundleEntryPath) throws IOException { super(getBaseFile(basefile, enableStrictBundleEntryPath)); if (!BundleFile.secureAction.exists(basefile) || !BundleFile.secureAction.isDirectory(basefile)) { throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_EXCEPTION, basefile)); } this.enableStrictBundleEntryPath = enableStrictBundleEntryPath; }
public BundleEntry getEntry(String path) { File filePath = getFile(path, false); if (filePath == null) return null; return new FileBundleEntry(filePath, path); }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<String>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<String>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleEntry getEntry(String path) { File filePath = getFile(path, false); if (filePath == null) return null; return new FileBundleEntry(filePath, path); }
/** * Constructs a DirBundleFile * @param basefile the base file * @throws IOException */ public DirBundleFile(File basefile, boolean enableStrictBundleEntryPath) throws IOException { super(getBaseFile(basefile, enableStrictBundleEntryPath)); if (!BundleFile.secureAction.exists(basefile) || !BundleFile.secureAction.isDirectory(basefile)) { throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_EXCEPTION, basefile)); } this.enableStrictBundleEntryPath = enableStrictBundleEntryPath; }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<String>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleEntry getEntry(String path) { File filePath = getFile(path, false); if (filePath == null) return null; return new FileBundleEntry(filePath, path); }
/** * Constructs a DirBundleFile * @param basefile the base file * @throws IOException */ public DirBundleFile(File basefile, boolean enableStrictBundleEntryPath) throws IOException { super(getBaseFile(basefile, enableStrictBundleEntryPath)); if (!BundleFile.secureAction.exists(basefile) || !BundleFile.secureAction.isDirectory(basefile)) { throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_EXCEPTION, basefile)); } this.enableStrictBundleEntryPath = enableStrictBundleEntryPath; }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<String>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleEntry getEntry(String path) { File filePath = getFile(path, false); if (filePath == null) return null; return new FileBundleEntry(filePath, path); }
/** * Constructs a DirBundleFile * @param basefile the base file * @throws IOException */ public DirBundleFile(File basefile, boolean enableStrictBundleEntryPath) throws IOException { super(getBaseFile(basefile, enableStrictBundleEntryPath)); if (!BundleFile.secureAction.exists(basefile) || !BundleFile.secureAction.isDirectory(basefile)) { throw new IOException(NLS.bind(Msg.ADAPTOR_DIRECTORY_EXCEPTION, basefile)); } this.enableStrictBundleEntryPath = enableStrictBundleEntryPath; }
public Enumeration<String> getEntryPaths(String path, boolean recurse) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); File pathFile = getFile(path, false); if (pathFile == null || !BundleFile.secureAction.isDirectory(pathFile)) return null; String[] fileList = BundleFile.secureAction.list(pathFile); if (fileList == null || fileList.length == 0) return null; String dirPath = path.length() == 0 || path.charAt(path.length() - 1) == '/' ? path : path + '/'; LinkedHashSet<String> entries = new LinkedHashSet<>(); for (String s : fileList) { java.io.File childFile = new java.io.File(pathFile, s); StringBuilder sb = new StringBuilder(dirPath).append(s); if (BundleFile.secureAction.isDirectory(childFile)) { sb.append("/"); //$NON-NLS-1$ if (recurse) { Enumeration<String> e = getEntryPaths(sb.toString(), true); if (e != null) entries.addAll(Collections.list(e)); } } entries.add(sb.toString()); } return Collections.enumeration(entries); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleEntry getEntry(String path) { File filePath = getFile(path, false); if (filePath == null) return null; return new FileBundleEntry(filePath, path); }