private boolean invariants() { assert null != getUri(); assert getUri().isAbsolute(); assert null == getUri().getRawQuery(); assert null == getUri().getRawFragment(); if (getUri().isOpaque()) { assert getUri().getRawSchemeSpecificPart().endsWith(SEPARATOR); final FsNodePath path = getPath(); assert null != path; assert path.getUri().isAbsolute(); assert null == path.getUri().getRawFragment(); assert 0 != path.getNodeName().getUri().getRawPath().length(); } else { assert getUri().normalize() == getUri(); assert getUri().getRawPath().endsWith(FsNodeName.SEPARATOR); assert null == getPath(); } return true; }
private FsPrefixMountPointFilter(final FsMountPoint prefix) { final URI prefixUri = prefix.toHierarchicalUri(); this.prefixScheme = prefixUri.getScheme(); this.prefixPath = prefixUri.getPath(); this.prefixPathLength = prefixPath.length(); this.prefixPathEndsWithSeparator = prefixPath.charAt(prefixPathLength - 1) == SEPARATOR_CHAR; }
@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(); }
if (null != enclArchive) { assert null != nodeName; return new FsMountPoint( scheme, new FsNodePath( new FsMountPoint(enclArchive.toURI(), CANONICALIZE), nodeName)).getUri(); } else { return new FsMountPoint(scheme, new FsNodePath(file)).getUri(); new FsMountPoint(enclArchive.toURI(), CANONICALIZE), nodeName).getUri(); } else {
this.detector = detector; final FsMountPoint mp = path.getMountPoint(); final FsNodePath mpp = mp.getPath(); final FsNodeName nn; if (null == mpp) {
protected FsAbstractModel( final FsMountPoint mountPoint, final @CheckForNull FsModel parent) { if (!Objects.equals(mountPoint.getParent(), (null == parent ? null : parent.getMountPoint()))) throw new IllegalArgumentException("Parent/Member mismatch!"); this.mountPoint = mountPoint; this.parent = parent; }
FileController(final FsModel model) { super(model); if (null != model.getParent()) throw new IllegalArgumentException(); URI uri = model.getMountPoint().getUri(); if ('\\' == separatorChar && null != uri.getRawAuthority()) { try { // Postfix: Move Windows UNC host from authority to path // component because the File class can't deal with this. // Note that the authority parameter must not be null and that // you cannot use the UriBuilder class - using either of these // would result in the authority property of the new URI object // being equal to the original value again. // Note that the use of the buggy URI constructor is authorized // for this case! // See http://java.net/jira/browse/TRUEZIP-288 . uri = new URI( uri.getScheme(), "", TWO_SEPARATORS + uri.getAuthority() + uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } this.target = Paths.get(uri); }
/** * Constructs a new mount point by composing its URI from the given scheme * and path. * This static factory method calls * {@link #FsMountPoint(FsScheme, FsNodePath) new FsMountPoint(scheme, path)} * and wraps any thrown {@link URISyntaxException} in an * {@link IllegalArgumentException}. * * @param scheme the {@link #getScheme() scheme}. * @param path the {@link #getPath() path}. * @throws IllegalArgumentException if the composed mount point URI would * not conform to the syntax constraints for mount points. * @return A new mount point. */ public static FsMountPoint create(FsScheme scheme, FsNodePath path) { try { return new FsMountPoint(scheme, path); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
public FsSyncException(FsMountPoint mountPoint, Throwable cause) { super(mountPoint.toString(), cause); }
private FsDriver driver(final FsMountPoint mountPoint) { final FsScheme scheme = mountPoint.getScheme(); final FsDriver driver = get().get(scheme); if (null == driver) throw new ServiceConfigurationError(scheme + " (Unknown file system scheme! May be the class path doesn't contain the respective driver module or it isn't set up correctly?)"); return driver; } }
boolean equals(TPath p1, TPath p2) { return p1.getNodePath().getMountPoint().equals(p2.getNodePath().getMountPoint()) && p1.toString().equals(p2.toString()); }
"Missing mount point separator \"" + FsMountPoint.SEPARATOR + '"'); final UriBuilder b = new UriBuilder(true); mountPoint = new FsMountPoint( b.scheme(uri.getScheme()) .path(ssp.substring(0, i + 2)) modifier); if (NULL != modifier) { URI mpu = mountPoint.getUri(); URI nuri = new URI(mpu.getScheme() + ':' + mpu.getRawSchemeSpecificPart() + nodeName.getUri()); if (!uri.equals(nuri)) mountPoint = new FsMountPoint(uri.resolve(DOT), modifier); nodeName = new FsNodeName(mountPoint.getUri().relativize(uri), modifier); } else { mountPoint = null;
@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); } }
/** * 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(); }
/** * Constructs a new mount point by parsing the given URI. * This static factory method calls * {@link #FsMountPoint(URI, FsUriModifier) new FsMountPoint(uri, modifier)} * and wraps any thrown {@link URISyntaxException} in an * {@link IllegalArgumentException}. * * @param uri the {@link #getUri() URI}. * @param modifier the URI modifier. * @throws IllegalArgumentException if {@code uri} does not conform to the * syntax constraints for mount points. * @return A new mount point. */ public static FsMountPoint create(URI uri, FsUriModifier modifier) { try { return new FsMountPoint(uri, modifier); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
public FsReadOnlyFileSystemException(FsMountPoint mountPoint) { super(mountPoint.toString()); }
private @Nullable FsScheme getScheme() { if (this != innerArchive) return null; final FsController controller = this.controller; if (null != controller) return controller.getModel().getMountPoint().getScheme(); return getArchiveDetector().scheme(file.getPath()); }