/** * Returns the parent component, that is the mount point of the parent file * system, * or {@code null} iff this mount point's {@link #getUri URI} doesn't name * a parent mount point, that is if and only if it's hierarchical. * * @return The nullable parent component. */ public @Nullable FsMountPoint getParent() { assert null == path || null != path.getMountPoint(); return null == path ? null : path.getMountPoint(); }
@Override public FsMountPoint getMountPoint() { // TODO: Optimize this. return getNodePath().getMountPoint(); }
@Override public FsMountPoint getMountPoint() { return getNodePath().getMountPoint(); }
@Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") int hashCode(TPath p) { final Integer hashCode = p.hashCode; if (null != hashCode) return hashCode; int result = 17; result = 37 * result + p.getNodePath().getMountPoint().hashCode(); result = 37 * result + p.toString().toLowerCase(Locale.getDefault()).hashCode(); return p.hashCode = result; } } // WindowsTPathComparator
@Override boolean equals(TPath p1, TPath p2) { return p1.getNodePath().getMountPoint().equals(p2.getNodePath().getMountPoint()) && p1.toString().equalsIgnoreCase(p2.toString()); }
boolean equals(TPath p1, TPath p2) { return p1.getNodePath().getMountPoint().equals(p2.getNodePath().getMountPoint()) && p1.toString().equals(p2.toString()); }
@SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") int hashCode(TPath p) { final Integer hashCode = p.hashCode; if (null != hashCode) return hashCode; int result = 17; result = 37 * result + p.getNodePath().getMountPoint().hashCode(); result = 37 * result + p.toString().hashCode(); return p.hashCode = result; } } // TPathComparator
/** * 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); } } }
private boolean invariants() { assert null != getUri(); assert null == getUri().getRawFragment(); assert (null != getMountPoint()) == getUri().isAbsolute(); assert null != getNodeName(); if (getUri().isOpaque()) { assert getUri().getRawSchemeSpecificPart().contains(FsMountPoint.SEPARATOR); /*try { assert getUri().equals(new URI(getMountPoint().getUri().getScheme(), getMountPoint().getUri().getSchemeSpecificPart() + toDecodedUri(getNodeName()), null)); } catch (URISyntaxException ex) { throw new AssertionError(ex); }*/ } else if (getUri().isAbsolute()) { assert getUri().normalize() == getUri(); assert getUri().equals(getMountPoint().getUri().resolve(getNodeName().getUri())); } else { assert getUri().normalize() == getUri(); assert getNodeName().getUri() == getUri(); } return true; }
this.file = new File(super.getPath()); this.detector = detector; final FsMountPoint mp = path.getMountPoint(); final FsNodePath mpp = mp.getPath(); final FsNodeName nn; assert path.getUri().isOpaque(); if (mpp.getUri().isOpaque()) { this.enclArchive = new TFile(mpp.getMountPoint(), detector); this.nodeName = mpp.getNodeName(); } else {
/** * 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; }
@SuppressWarnings("LeakingThisInConstructor") private TFile( final FsMountPoint mountPoint, final TArchiveDetector detector) { super(mountPoint.toHierarchicalUri()); this.file = new File(super.getPath()); this.detector = detector; final FsNodePath mpp = mountPoint.getPath(); if (null == mpp) { assert !mountPoint.getUri().isOpaque(); this.enclArchive = null; this.nodeName = null; this.innerArchive = null; } else { assert mountPoint.getUri().isOpaque(); if (mpp.getUri().isOpaque()) { this.enclArchive = new TFile(mpp.getMountPoint(), detector); this.nodeName = mpp.getNodeName(); } else { this.enclArchive = null; this.nodeName = null; } this.innerArchive = this; this.controller = getController(mountPoint); } assert invariants(); }
/** * 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(); }
.current() .getManager() .controller(detector(file), path.getMountPoint()) .output( options.clear(CREATE_PARENTS), path.getNodeName(),
/** * Returns an input socket for the given file. * * @param file the file to read. * @param options the options for accessing the file. * @return An input socket for the given file. */ static InputSocket<?> input( final BitField<FsAccessOption> options, final File file) { if (file instanceof TFile) { final TFile tfile= (TFile) file; final TFile archive = tfile.getInnerArchive(); if (null != archive) return archive .getController() .input(options, tfile.getNodeName()); } final FsNodePath path = new FsNodePath(file); return TConfig .current() .getManager() .controller(detector(file), path.getMountPoint()) .input(options, path.getNodeName()); }