/** * Resolves the given node name against this path. * * @param nodeName a node name relative to this path. * @return A new path with an absolute URI. */ public FsNodePath resolve(final FsNodeName nodeName) { if (nodeName.isRoot() && null == this.uri.getQuery()) return this; return new FsNodePath( this.mountPoint, new FsNodeName(this.nodeName, nodeName)); }
if (null == mountPoint) { this.uri = nodeName.getUri(); } else if (nodeName.isRoot()) { this.uri = mountPoint.getUri(); } else if ((mpu = mountPoint.getUri()).isOpaque()) {
/** * Returns the nullable parent of the given file system node path. * * @param path a file system node path. * @return The parent file system node path or null if {@code path} does * not name a parent. * @throws URISyntaxException */ static @Nullable FsNodePath parent(FsNodePath path) throws URISyntaxException { FsMountPoint mp = path.getMountPoint(); FsNodeName en = path.getNodeName(); if (en.isRoot()) { if (null == mp) return null; path = mp.getPath(); if (null != path) return parent(path); URI mpu = mp.getUri(); URI pu = mpu.resolve(DOT_DOT_URI); if (mpu.getRawPath().length() <= pu.getRawPath().length()) return null; return new FsNodePath(pu); } else { URI pu = en.getUri().resolve(DOT_URI); en = new FsNodeName(pu, CANONICALIZE); return new FsNodePath(mp, en); } } }
/** * Returns {@code true} if and only if this {@code TPath} addresses an * archive file. * Whether or not this is true solely depends on the * {@link TArchiveDetector} which was used to construct this {@code TPath} * - no file system tests are performed by this method! * * @return {@code true} if and only if this {@code TPath} addresses an * archive file. * @see #isEntry */ public boolean isArchive() { final FsNodePath nodePath = getNodePath(); final boolean root = nodePath.getNodeName().isRoot(); final FsMountPoint parent = nodePath.getMountPoint().getParent(); return root && null != parent; }
this.nodeName = null; this.innerArchive = null; } else if ((nn = path.getNodeName()).isRoot()) { assert path.getUri().isOpaque(); if (mpp.getUri().isOpaque()) {
/** * Returns {@code true} if and only if this {@code TPath} addresses an * entry located within an archive file. * Whether or not this is true solely depends on the * {@link TArchiveDetector} which was used to construct this {@code TPath} * - no file system tests are performed by this method! * * @return {@code true} if and only if this {@code TPath} addresses an * entry located within an archive file. * @see #isArchive */ public boolean isEntry() { final FsNodePath nodePath = getNodePath(); final boolean root = nodePath.getNodeName().isRoot(); final FsMountPoint parent = nodePath.getMountPoint().getParent(); return !root ? null != parent : null != parent && null != parent.getParent(); }
@Override public final void unlink( final BitField<FsAccessOption> options, final FsNodeName name) throws IOException { try { controller.unlink(options, name); } catch (final ControlFlowException ex) { // If the exception is caused by a key exception, then throw this // cause instead in order to avoid treating the target archive file // like a false positive and routing this operation to the parent // file system. // This prevents the application from inadvertently deleting an // encrypted ZIP file just because the user cancelled key prompting. final IOException keyEx = findKeyException(ex); if (null == keyEx) throw ex; throw keyEx; } final FsModel model = getModel(); final URI mpu = driver.mountPointUri(model); final URI fsu = driver.fileSystemUri(model, name.toString()); if (!fsu.equals(mpu) || name.isRoot()) keyManager().unlink(fsu); }
@Override public void checkAccess( final BitField<FsAccessOption> options, final FsNodeName name, final BitField<Access> types) throws IOException { try { controller.checkAccess(options, name, types); } catch (final ControlFlowException ex) { if (!name.isRoot() || null == findKeyException(ex)) throw ex; getParent().checkAccess( options, getModel() .getMountPoint() .getPath() .resolve(name) .getNodeName(), types); } }
private FsNodePath resolve(final String path) throws URISyntaxException { splitter.split(path); final String pp = splitter.getParentPath(); final FsNodeName nn; final FsNodePath np; if (null != pp) { nn = new FsNodeName( builder.path(splitter.getMemberName()).getUri(), NULL); np = resolve(pp); } else { nn = new FsNodeName( builder.path(path).query(memberQuery).getUri(), CANONICALIZE); np = root; } URI npu; FsNodePath rnp; if (nn.isRoot() || (npu = np.getUri()).isOpaque() || !npu.isAbsolute()) { rnp = np.resolve(nn); } else { final String npup = npu.getPath(); if (!npup.endsWith(SEPARATOR)) npu = new UriBuilder(npu).path(npup + SEPARATOR_CHAR).getUri(); rnp = new FsNodePath(new FsMountPoint(npu), nn); } final FsScheme s = detector.scheme(nn.toString()); if (null != s) rnp = new FsNodePath(new FsMountPoint(s, rnp), ROOT); return rnp; }
return controller.node(options, name); } catch (final ControlFlowException ex) { if (!name.isRoot() || null == findKeyException(ex)) throw ex; Entry node = getParent().node(