Java 类java.nio.file.NotLinkException 实例源码

项目:mux2fs    文件:MirrorFs.java   
protected final int translateOrThrow(Exception exception) {
    return ExceptionTranslator.<Integer, Exception> of(exception) //
            .translate(AccessDeniedException.class, e -> -ErrorCodes.EPERM()) //
            .translate(NoSuchFileException.class, e -> -ErrorCodes.ENOENT()) //
            .translate(NotDirectoryException.class, e -> -ErrorCodes.ENOTDIR()) //
            .translate(NotLinkException.class, e -> -ErrorCodes.EINVAL()) //
            .translate(UnsupportedOperationException.class, e -> -ErrorCodes.ENOSYS()) //
            .translate(IOException.class, e -> {
                logger.warn("", e); // Unmapped IOException, log warning
                return -ErrorCodes.EIO();
            }).get();
}
项目:mux2fs    文件:Fixture.java   
protected void testAllErrors(Try.CheckedConsumer<ExpectedResult, Exception> sut)
        throws Exception {
    List<ExpectedResult> list = list( //
            exp(new NoSuchFileException(null), -ErrorCodes.ENOENT()), //
            exp(new AccessDeniedException(null), -ErrorCodes.EPERM()), //
            exp(new NotDirectoryException(null), -ErrorCodes.ENOTDIR()), //
            exp(new NotLinkException(null), -ErrorCodes.EINVAL()), //
            exp(new UnsupportedOperationException(), -ErrorCodes.ENOSYS()), //
            exp(new IOException(), -ErrorCodes.EIO())); //
    list.forEach(expected -> Try.runWithCatch(() -> sut.accept(expected), Exception.class).get());
}
项目:intellij    文件:BlazeGoGotoDeclarationHandlerTest.java   
@Override
public File readSymbolicLink(File link) throws IOException {
  if (!isSymbolicLink(link)) {
    throw new NotLinkException(link.getPath());
  }
  VirtualFile vf = fileSystem.findFile(link.getPath());
  return VfsUtil.virtualToIoFile(symlinks.get(vf));
}
项目:ephemeralfs    文件:INode.java   
public EphemeralFsPath getRawSymbolicLink(Path parent, EphemeralFsPath fileName) throws FileSystemException {
    DirectoryEntry entry = children.get(fileName.toFileName());
    if(entry == null) {
        throw new NoSuchFileException(parent.resolve(fileName).toString());
    }
    if(!entry.isSymbolicLink()) {
        throw new NotLinkException(parent.resolve(fileName).toString());
    }
    return entry.getSymbolicLink();
}
项目:ephemeralfs    文件:LinkTest.java   
@Test
public void testReadSymbolicLinkNoSymbolicLink() throws Exception {
    Path notSymLink = root.resolve("notSymLink");
    Files.createDirectories(notSymLink);
    try {
        Files.readSymbolicLink(notSymLink);
        fail();
    } catch(NotLinkException e) {
        //pass
    }
}
项目:buck    文件:FakeProjectFilesystem.java   
@Override
public Path readSymLink(Path path) throws IOException {
  Path target = symLinks.get(path);
  if (target == null) {
    throw new NotLinkException(path.toString());
  }
  return target;
}
项目:jimfs    文件:DirectoryEntry.java   
/**
 * Checks that this entry exists and links to a symbolic link, throwing an exception if not.
 *
 * @return this
 * @throws NoSuchFileException if this entry does not exist
 * @throws NotLinkException if this entry does not link to a symbolic link
 */
public DirectoryEntry requireSymbolicLink(Path pathForException)
    throws NoSuchFileException, NotLinkException {
  requireExists(pathForException);
  if (!file().isSymbolicLink()) {
    throw new NotLinkException(pathForException.toString());
  }
  return this;
}
项目:niotest    文件:Tests20SymLinks.java   
@Test( expected = NotLinkException.class )
@Category( { SymLink.class } )
public void testGetSymLinkOfNonLinkThrows() throws IOException {
    Files.readSymbolicLink( targetFile() );
}