/** * Returns a FileObject representing the root folder of an archive. * Clients may need to first call {@link #isArchiveFile(FileObject)} to determine * if the file object refers to an archive file. * @param fo a ZIP- (or JAR-) format archive file * @return a virtual archive root folder, or null if the file is not actually an archive * @since 4.48 */ public static FileObject getArchiveRoot(FileObject fo) { URL archiveURL = URLMapper.findURL(fo, URLMapper.EXTERNAL); if (archiveURL == null) { return null; } return URLMapper.findFileObject(getArchiveRoot(archiveURL)); }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); assert fsname != null : "Should always have a non-null fsname here"; @SuppressWarnings("deprecation") // historical part of serial form FileSystem fs = Repository.getDefault().findFileSystem(fsname); if (fs != null) { assert path != null : "Should always have a non-null path here"; f = fs.findResource(path); } if (f == null) { // Fall back to URL. assert url != null : "Should always have a non-null URL here"; f = URLMapper.findFileObject(url); if (f == null) { throw new FileNotFoundException("Could not restore: " + url); // NOI18N } } }
/** * Tests if a URL represents a JAR or ZIP archive. * If there is no such file object, the test is done by heuristic: any URL with an extension is * treated as an archive. * @param url a URL to a file * @return true if the URL seems to represent a ZIP-format archive * @since 4.48 */ public static boolean isArchiveFile(URL url) { Parameters.notNull("url", url); //NOI18N if ("jar".equals(url.getProtocol())) { //NOI18N //Already inside archive, return false return false; } FileObject fo = URLMapper.findFileObject(url); if ((fo != null) && !fo.isVirtual()) { if (LOG.isLoggable(Level.FINEST)) { LOG.log(Level.FINEST, "isArchiveFile_FILE_RESOLVED", fo); //NOI18N, used by FileUtilTest.testIsArchiveFileRace } return isArchiveFile(fo); } else { return isArchiveFile(url.getPath()); } }
try { URL url = Utilities.toURI(file).toURL(); retVal = URLMapper.findFileObject(url);
public R (final URL sourceRootURL, final SourceForBinaryQuery.Result delegate) { assert sourceRootURL != null; this.sourceRoot = URLMapper.findFileObject(sourceRootURL); this.delegate = delegate; }
protected FileObject resolveToFileObject(URL url) { if (url == null) return null; FileObject file = URLMapper.findFileObject(url); return file; }
private static FileObject getFileObjectFromUrl(String url) { FileObject fo = null; try { fo = URLMapper.findFileObject(new URL(url)); } catch (MalformedURLException e) { //noop } return fo; }
public static FileObject getFileObjectFromUrl(String url) { FileObject fo = null; try { fo = URLMapper.findFileObject(new URL(url)); } catch (MalformedURLException e) { //noop } return fo; }
private FileObject toFileObject(URI uri) { try { URL url = uri.toURL(); return URLMapper.findFileObject(url); } catch (MalformedURLException ex) { Exceptions.printStackTrace(ex); } return null; }
private FileObject findLayerParent() throws IOException { String loc = location.toExternalForm(); int slash = loc.lastIndexOf('/'); assert slash != -1 : loc; FileObject parent = URLMapper.findFileObject(new URL(loc.substring(0, slash + 1))); if (parent == null) { throw new IOException(loc); } return parent; }
public String getDisplayName() { FileObject fo = URLMapper.findFileObject(location); if (fo != null) { return FileUtil.getFileDisplayName(fo); } else { return location.toExternalForm(); } }
private boolean isWithin(URI[] res, FileObject file) throws MalformedURLException { for (URI ur : res) { FileObject fo = URLMapper.findFileObject(ur.toURL()); if (fo != null && (fo.equals(file) || FileUtil.isParentOf(fo, file))) { return true; } } return false; }
public void refresh() { try { if (URLMapper.findFileObject(url) != null) { /* Link to original file was repaired */ this.setValid(false); } } catch (Exception e) { } }
@Override public void restore() throws IOException { FileObject file = URLMapper.findFileObject(url); if (file != null) { file.delete(); } } };
@Override public FileObject[] getBinaryRoots() { final Queue<FileObject> res = new ArrayDeque<>(); if(getType() == Type.BINARY) { final FileObject fo = URLMapper.findFileObject (this.root); if (fo != null) { res.offer(fo); } } return res.toArray(new FileObject[res.size()]); }
ListItem(T o) { this.o = o; if (o instanceof FileObject) this.str = J2MEPlatform.getFilePath((FileObject) o); else if (o instanceof URL) this.str = J2MEPlatform.getFilePath(URLMapper.findFileObject((URL) o)); if (this.str == null) this.str = o != null ? o.toString() : ""; // NOI18N }
ListItem(T o) { this.o = o; if (o instanceof FileObject) this.str = J2MEPlatform.getFilePath((FileObject) o); else if (o instanceof URL) this.str = J2MEPlatform.getFilePath(URLMapper.findFileObject((URL) o)); if (this.str == null) this.str = o != null ? o.toString() : ""; // NOI18N }
private FileObject getAptRoot (final javax.tools.FileObject sibling) { final URL ownerRoot = getOwnerRoot (sibling); if (ownerRoot == null) { return null; } final URL aptRoot = AptCacheForSourceQuery.getAptFolder(ownerRoot); return aptRoot == null ? null : URLMapper.findFileObject(aptRoot); }
private static Set<Item> getDriverItems(String driverClass) { Set<Item> result = new HashSet<Item>(); for (URL url : getDriverURLs(driverClass)) { FileObject fo = URLMapper.findFileObject(url); result.add(Item.create(FileUtil.toFile(fo), null)); } return result; }
@CheckForNull private FileObject getRoot() { FileObject res = cachedRoot; if (res == null || !res.isValid()) { cachedRoot = res = URLMapper.findFileObject(root); } return res; }