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

项目:pgcodekeeper    文件:ModelExporter.java   
private File mkdirObjects(File parentOutDir, String outDirName)
        throws NotDirectoryException, DirectoryException {
    File objectDir = new File(parentOutDir, outDirName);

    if(objectDir.exists()) {
        if(!objectDir.isDirectory()) {
            throw new NotDirectoryException(objectDir.getAbsolutePath());
        }
    } else {
        if(!objectDir.mkdir()) {
            throw new DirectoryException(MessageFormat.format(
                    "Could not create objects directory: {0}",
                    objectDir.getAbsolutePath()));
        }
    }
    return objectDir;
}
项目:elasticsearch_my    文件:FileUtils.java   
/**
 * Returns the json files found within the directory provided as argument.
 * Files are looked up in the classpath, or optionally from {@code fileSystem} if its not null.
 */
public static Set<Path> findJsonSpec(FileSystem fileSystem, String optionalPathPrefix, String path) throws IOException {
    Path dir = resolveFile(fileSystem, optionalPathPrefix, path, null);

    if (!Files.isDirectory(dir)) {
        throw new NotDirectoryException(path);
    }

    Set<Path> jsonFiles = new HashSet<>();
    try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
        for (Path item : stream) {
            if (item.toString().endsWith(JSON_SUFFIX)) {
                jsonFiles.add(item);
            }
        }
    }

    if (jsonFiles.isEmpty()) {
        throw new NoSuchFileException(path, null, "no json files found");
    }

    return jsonFiles;
}
项目:elasticsearch_my    文件:Security.java   
/**
 * Ensures configured directory {@code path} exists.
 * @throws IOException if {@code path} exists, but is not a directory, not accessible, or broken symbolic link.
 */
static void ensureDirectoryExists(Path path) throws IOException {
    // this isn't atomic, but neither is createDirectories.
    if (Files.isDirectory(path)) {
        // verify access, following links (throws exception if something is wrong)
        // we only check READ as a sanity test
        path.getFileSystem().provider().checkAccess(path.toRealPath(), AccessMode.READ);
    } else {
        // doesn't exist, or not a directory
        try {
            Files.createDirectories(path);
        } catch (FileAlreadyExistsException e) {
            // convert optional specific exception so the context is clear
            IOException e2 = new NotDirectoryException(path.toString());
            e2.addSuppressed(e);
            throw e2;
        }
    }
}
项目:elasticsearch_my    文件:ExceptionSerializationTests.java   
public void testFileSystemExceptions() throws IOException {
    for (FileSystemException ex : Arrays.asList(new FileSystemException("a", "b", "c"),
        new NoSuchFileException("a", "b", "c"),
        new NotDirectoryException("a"),
        new DirectoryNotEmptyException("a"),
        new AtomicMoveNotSupportedException("a", "b", "c"),
        new FileAlreadyExistsException("a", "b", "c"),
        new AccessDeniedException("a", "b", "c"),
        new FileSystemLoopException("a"))) {

        FileSystemException serialize = serialize(ex);
        assertEquals(serialize.getClass(), ex.getClass());
        assertEquals("a", serialize.getFile());
        if (serialize.getClass() == NotDirectoryException.class ||
            serialize.getClass() == FileSystemLoopException.class ||
            serialize.getClass() == DirectoryNotEmptyException.class) {
            assertNull(serialize.getOtherFile());
            assertNull(serialize.getReason());
        } else {
            assertEquals(serialize.getClass().toString(), "b", serialize.getOtherFile());
            assertEquals(serialize.getClass().toString(), "c", serialize.getReason());
        }
    }
}
项目:Elasticsearch    文件:Security.java   
/**
 * Ensures configured directory {@code path} exists.
 * @throws IOException if {@code path} exists, but is not a directory, not accessible, or broken symbolic link.
 */
static void ensureDirectoryExists(Path path) throws IOException {
    // this isn't atomic, but neither is createDirectories.
    if (Files.isDirectory(path)) {
        // verify access, following links (throws exception if something is wrong)
        // we only check READ as a sanity test
        path.getFileSystem().provider().checkAccess(path.toRealPath(), AccessMode.READ);
    } else {
        // doesn't exist, or not a directory
        try {
            Files.createDirectories(path);
        } catch (FileAlreadyExistsException e) {
            // convert optional specific exception so the context is clear
            IOException e2 = new NotDirectoryException(path.toString());
            e2.addSuppressed(e);
            throw e2;
        }
    }
}
项目:openjdk-jdk10    文件:JrtFileSystem.java   
/**
 * returns the list of child paths of the given directory "path"
 *
 * @param path name of the directory whose content is listed
 * @return iterator for child paths of the given directory path
 */
Iterator<Path> iteratorOf(JrtPath path, DirectoryStream.Filter<? super Path> filter)
        throws IOException {
    Node node = checkNode(path).resolveLink(true);
    if (!node.isDirectory()) {
        throw new NotDirectoryException(path.getName());
    }
    if (filter == null) {
        return node.getChildren()
                   .stream()
                   .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
                   .iterator();
    }
    return node.getChildren()
               .stream()
               .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
               .filter(p ->  { try { return filter.accept(p);
                               } catch (IOException x) {}
                               return false;
                              })
               .iterator();
}
项目:openjdk9    文件:JrtFileSystem.java   
/**
 * returns the list of child paths of the given directory "path"
 *
 * @param path name of the directory whose content is listed
 * @return iterator for child paths of the given directory path
 */
Iterator<Path> iteratorOf(JrtPath path, DirectoryStream.Filter<? super Path> filter)
        throws IOException {
    Node node = checkNode(path).resolveLink(true);
    if (!node.isDirectory()) {
        throw new NotDirectoryException(path.getName());
    }
    if (filter == null) {
        return node.getChildren()
                   .stream()
                   .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
                   .iterator();
    }
    return node.getChildren()
               .stream()
               .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
               .filter(p ->  { try { return filter.accept(p);
                               } catch (IOException x) {}
                               return false;
                              })
               .iterator();
}
项目:amq-kahadb-tool    文件:KahaDBJournalsReader.java   
public void showData(String sourceDirPath, boolean useAnyKeyToContinue) throws NotDirectoryException {
    if(isNullOrEmpty(sourceDirPath)) {
        throw new NullPointerException("sourceDirPath");
    }

    File sourceDir = new File(sourceDirPath);
    if(!sourceDir.isDirectory()) {
        throw new NotDirectoryException("sourceDirPath");
    }

    try {
        showData(sourceDir, useAnyKeyToContinue);
    }
    catch (Throwable throwable) {
        showException(throwable);
    }
}
项目:amq-kahadb-tool    文件:KahaDBJournalsStatistics.java   
public void showStatistic(String sourceDirPath, boolean useAnyKeyToContinue) throws NotDirectoryException {
    if(isNullOrEmpty(sourceDirPath)) {
        throw new NullPointerException("sourceDirPath");
    }

    File sourceDir = new File(sourceDirPath);
    if(!sourceDir.isDirectory()) {
        throw new NotDirectoryException("sourceDirPath");
    }

    try {
        showStatistic(sourceDir, useAnyKeyToContinue);
    }
    catch (Throwable throwable) {
        showException(throwable);
    }
}
项目:mycore    文件:MCRGoogleSitemapCommon.java   
/** The constructor 
 * @throws NotDirectoryException */
public MCRGoogleSitemapCommon(File baseDir) throws NotDirectoryException {
    if (!Objects.requireNonNull(baseDir, "baseDir may not be null.").isDirectory()) {
        throw new NotDirectoryException(baseDir.getAbsolutePath());
    }
    this.webappBaseDir = baseDir;
    LOGGER.info("Using webappbaseDir: {}", baseDir.getAbsolutePath());
    objidlist = new ArrayList<>();
    if ((numberOfURLs < 1) || (numberOfURLs > 50000))
        numberOfURLs = 50000;
    if (cdir.length() != 0) {
        File sitemap_directory = new File(webappBaseDir, cdir);
        if (!sitemap_directory.exists()) {
            sitemap_directory.mkdirs();
        }
    }
}
项目:mycore    文件:MCRFileSystemProvider.java   
private static MCRDirectory getParentDirectory(MCRPath mcrPath) throws NoSuchFileException, NotDirectoryException {
    if (mcrPath.getNameCount() == 0) {
        throw new IllegalArgumentException("Root component has no parent: " + mcrPath);
    }
    MCRDirectory rootDirectory = getRootDirectory(mcrPath);
    if (mcrPath.getNameCount() == 1) {
        return rootDirectory;
    }
    MCRPath parentPath = mcrPath.getParent();
    MCRFilesystemNode parentNode = rootDirectory.getChildByPath(getAbsolutePathFromRootComponent(parentPath)
        .toString());
    if (parentNode == null) {
        throw new NoSuchFileException(rootDirectory.toPath().toString(), getAbsolutePathFromRootComponent(mcrPath)
            .toString(), "Parent directory does not exists.");
    }
    if (parentNode instanceof MCRFile) {
        throw new NotDirectoryException(parentNode.toPath().toString());
    }
    MCRDirectory parentDir = (MCRDirectory) parentNode;
    parentDir.getChildren();//warm-up cache
    return parentDir;
}
项目:mycore    文件:MCRFileSystemProvider.java   
static MCRFilesystemNode resolvePath(MCRPath path) throws IOException {
    try {
        String ifsid = nodeCache.getUnchecked(path);
        MCRFilesystemNode node = MCRFilesystemNode.getNode(ifsid);
        if (node != null) {
            return node;
        }
        nodeCache.invalidate(path);
        return resolvePath(path);
    } catch (UncheckedExecutionException e) {
        Throwable cause = e.getCause();
        if (cause instanceof NoSuchFileException) {
            throw (NoSuchFileException) cause;
        }
        if (cause instanceof NotDirectoryException) {
            throw (NotDirectoryException) cause;
        }
        if (cause instanceof IOException) {
            throw (IOException) cause;
        }
        throw e;
    }
}
项目:JCore-UtilLibrary    文件:FileSearchUtils.java   
/**
 * 获得一个文件目录下的所有文件名称(只包含文件名本身)
 * 
 * @param folderName
 *      文件目录
 * @return
 *      文件名称数组
 * @throws FileNameNotExistsException
 *      文件名不存在异常
 * @throws NotDirectoryException
 *      不是目录异常
 */
public static String[] getAllFileName(String folderName) throws FileNameNotExistsException, NotDirectoryException {
    if (StringUtils.isEmpty(folderName)) {
        throw new NullPointerException("目录名为空,请输入文件目录");
    }

    File folderFile = new File(folderName);
    if (!folderFile.exists()) {
        throw new FileNameNotExistsException(folderName + "当前文件目录不存在");
    }

    if (!folderFile.isDirectory()) {
        throw new NotDirectoryException(folderName + "不是目录");
    }

    return folderFile.list();
}
项目:JCore-UtilLibrary    文件:FileSearchUtils.java   
/**
 * 获得一个文件目录下的所有文件
 * 
 * @param folderName
 *      文件目录
 * @return
 *      子文件
 * @throws FileNameNotExistsException
 *      文件名不存在异常
 * @throws NotDirectoryException
 *      不是目录异常
 */
public static File[] getAllSubFiles(String folderName) throws FileNameNotExistsException, NotDirectoryException {
    if (StringUtils.isEmpty(folderName)) {
        throw new NullPointerException("目录名为空,请输入文件目录");
    }

    File folderFile = new File(folderName);
    if (!folderFile.exists()) {
        throw new FileNameNotExistsException(folderName + "当前文件目录不存在");
    }

    if (!folderFile.isDirectory()) {
        throw new NotDirectoryException(folderName + "不是目录");
    }

    return folderFile.listFiles();
}
项目:appengine-plugins-core    文件:FilePermissions.java   
/**
 * Check whether the current process can create a directory at the specified path. This is useful
 * for providing immediate feedback to an end user that a path they have selected or typed may not
 * be suitable before attempting to create the directory; e.g. in a tooltip.
 *
 * @param path tentative location for directory
 * @throws AccessDeniedException if a directory in the path is not writable
 * @throws NotDirectoryException if a segment of the path is a file
 */
public static void verifyDirectoryCreatable(Path path)
    throws AccessDeniedException, NotDirectoryException {

  for (Path segment = path; segment != null; segment = segment.getParent()) {
    if (Files.exists(segment)) {
      if (Files.isDirectory(segment)) {
        // Can't create a directory if the bottom most currently existing directory in
        // the path is not writable.
        if (!Files.isWritable(segment)) {
          throw new AccessDeniedException(segment + " is not writable");
        }
      } else {
        // Can't create a directory if a non-directory file already exists with that name
        // somewhere in the path.
        throw new NotDirectoryException(segment + " is a file");
      }
      break;
    }
  }
}
项目:CorpusSpider    文件:ExtractionHTMLText.java   
private void parserURL() throws NotDirectoryException, FileNameNotExistsException {
    String[] fileNames = FileSearchUtils.getAllFileName(Constants.RAW_PATH);
    for (String fileName : fileNames) {
        try {
            AtomicInteger urlIndex = new AtomicInteger(0);
            List<String> urList = FileReadUtils.readLines(Constants.RAW_PATH + fileName);
            for (String url : urList) {
                mPool.submit(new ParserHTMLRunnable(splitWordUtils, url, FileUtils.removeSuffixName(fileName), StringUtils.formatIntegerString(urlIndex.get(), "#00000")), 3000);
                urlIndex.incrementAndGet();

                ThreadUtils.sleep(50);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        System.out.println("" + fileName);
    }
}
项目:Style    文件:Directory.java   
public Directory mkdir(String dir) throws FileAlreadyExistsException, FileOperationFailedException {
        dir = dir.trim();
        try {
                cd(dir);
        } catch (FileNotFoundException e) {
                File f;
                if (dir.startsWith("/")) {
                        f = new File(dir);
                } else {
                        f = new File(fullPath() + dir);
                }
                if (!f.mkdir()) throw new FileOperationFailedException("mkdir " + dir);
                try {
                        return new Directory(f);
                } catch (FileNotFoundException | NotDirectoryException e1) {
                        throw Style.$(e1);
                }
        } catch (NotDirectoryException ignore) {
        }
        throw new FileAlreadyExistsException(fullPath() + " " + dir);
}
项目:Style    文件:TestStyle.java   
@Test
public void testCDAndFile() throws Exception {
        Directory dir = cd("/Volumes/PROJECTS/prj");
        dir.mkdir("testTmp");
        dir = dir.cd("testTmp");
        try (SFile file = dir.file("tmp.txt")) {
                Writer writer = file.writer();
                writer.write("hello world");
                writer.flush();
        }

        try (SFile file = dir.file("tmp.txt")) {
                assertEquals("hello world", file.reader().readLine());
        }

        rm(dir.file("tmp.txt"));
        rm(dir);

        try {
                cd("/Volumes/PROJECTS/prj/testTmp");
                fail();
        } catch (FileNotFoundException | NotDirectoryException ignore) {
        }
}
项目:ephemeralfs    文件:INode.java   
private void assertCanAddChild(EphemeralFsPath name) throws IOException {
    if(isFile()) {
        throw new NotDirectoryException("can't add children to file");
    }
    if(name.toString().equals(".") || name.toString().equals("..")) {
        throw new IllegalStateException("invalid path:" + name);
    }
    if(fs.getSettings().getMaxPathLength() != Long.MAX_VALUE &&
            getPathToRoot().resolve(name).toString().length() > fs.getSettings().getMaxPathLength()) {
        throw new FileSystemException("Path too long");
    }

    assertOnlyFileName(name);
    if(children.containsKey(name.toFileName())) {
        throw new FileAlreadyExistsException("a child with name:" + name + " already exists");
    }
}
项目:ephemeralfs    文件:WatchServiceTest.java   
@Test
public void testRegisterNonDirectory() throws IOException, Exception {

    Path file = root.resolve("file");
    Files.createFile(file);


    try(WatchService service = root.getFileSystem().newWatchService()) {
        try
        {
            file.register(service, StandardWatchEventKinds.ENTRY_MODIFY);
            fail();
        } catch(NotDirectoryException e) {
            //pass
        }
    }

}
项目:jigsaw-jrtfs    文件:JrtDirectoryStream.java   
JrtDirectoryStream(JrtPath jrtPath,
                   DirectoryStream.Filter<? super java.nio.file.Path> filter)
    throws IOException
{
    this.jrtfs = jrtPath.getFileSystem();
    this.path = jrtPath.getResolvedPath();
    // sanity check
    if (!jrtfs.isDirectory(path))
        throw new NotDirectoryException(jrtPath.toString());

    // absolute path and does not have funky chars in front like /./java.base
    if (jrtPath.isAbsolute() && (path.length == jrtPath.getPathLength())) {
        childPrefix = null;
    } else {
        // cases where directory content needs to modified with prefix
        // like ./java.base, /./java.base, java.base and so on.
        String dirName = jrtPath.toString();
        int idx = dirName.indexOf(JrtFileSystem.getString(path).substring(1));
        childPrefix = dirName.substring(0, idx);
    }
    this.filter = filter;
}
项目:BitcoinLottery    文件:LotteryUtils.java   
static public File getDir(String[] pathParts) throws IOException {
    Set<PosixFilePermission> permissions = new HashSet<PosixFilePermission>();
    permissions.add(PosixFilePermission.OWNER_READ);
    permissions.add(PosixFilePermission.OWNER_WRITE);
    permissions.add(PosixFilePermission.OWNER_EXECUTE);

    File dir = new File("/");
    for (String name : pathParts) {
        dir = new File(dir, name);
        dir.mkdir();
        if (dir.isFile()) {
            throw new NotDirectoryException(dir.getAbsolutePath());
        }
        Files.setPosixFilePermissions(dir.toPath(), permissions);           
    }

    return dir;
}
项目:minikube-build-tools-for-java    文件:Caches.java   
public Caches init() throws CacheMetadataCorruptedException, NotDirectoryException {
  if (baseCacheDirectory == null || applicationCacheDirectory == null) {
    throw new IllegalStateException(
        "Must initialize cache with both base image layer cache directory and application image layer cache directory");
  }
  return new Caches(baseCacheDirectory, applicationCacheDirectory);
}
项目:minikube-build-tools-for-java    文件:Cache.java   
/**
 * Initializes a cache with a directory. This also loads the cache metadata if it exists in the
 * directory.
 */
static Cache init(Path cacheDirectory)
    throws NotDirectoryException, CacheMetadataCorruptedException {
  if (!Files.isDirectory(cacheDirectory)) {
    throw new NotDirectoryException("The cache can only write to a directory");
  }
  CacheMetadata cacheMetadata = loadCacheMetadata(cacheDirectory);

  return new Cache(cacheDirectory, cacheMetadata);
}
项目:minikube-build-tools-for-java    文件:CacheTest.java   
@Test
public void testInit_notDirectory() throws CacheMetadataCorruptedException, IOException {
  Path tempFile = temporaryCacheDirectory.newFile().toPath();

  try {
    Cache.init(tempFile);
    Assert.fail("Cache should not be able to initialize on non-directory");

  } catch (NotDirectoryException ex) {
    Assert.assertEquals("The cache can only write to a directory", ex.getMessage());
  }
}
项目:smb-nio    文件:SMBDirectoryStream.java   
/**
 * Public and internal constructor for {@link SMBDirectoryStream}.
 *
 * @param smbPath The {@link SMBPath} for which to open a directory stream.
 * @param filter An optional filter predicate.
 *
 * @throws NotDirectoryException If provided {@link SMBPath} does not point to a directory.
 * @throws IOException If something goes wrong while reading the content of the directory.
 */
public SMBDirectoryStream(SMBPath smbPath, java.nio.file.DirectoryStream.Filter<? super Path> filter) throws IOException {
    if (!smbPath.getSmbFile().isDirectory()) throw new NotDirectoryException("The provided path '" + smbPath.toString() + "' is not a directory.");
    this.content = new ArrayList<>();
    for (String name : smbPath.getSmbFile().list()) {
        final Path path = smbPath.resolve(name);
        if (filter == null || filter.accept(path)) {
            this.content.add(path);
        }
    }
}
项目:truevfs    文件:TBIO.java   
/** Unchecked parameters version. */
private static void
cp_r0(  final boolean preserve,
        final File src,
        final File dst,
        final TArchiveDetector srcDetector,
        final TArchiveDetector dstDetector)
throws IOException {
    if (src.isDirectory()) {
        final long srcLastModified = src.lastModified();
        final boolean srcArchived = src instanceof TFile
                && null != ((TFile) src).getInnerArchive();
        final boolean dstArchived = dst instanceof TFile
                && null != ((TFile) dst).getInnerArchive();
        final boolean srcIsGhost = srcArchived && 0 >= srcLastModified;
        if (!srcIsGhost || !dstArchived || !TConfig.current().isLenient())
            if (!dst.mkdir() && !dst.isDirectory())
                throw new NotDirectoryException(dst.getPath());
        final String[] members = src.list();
        if (null == members)
            throw new FileSystemException(dst.getPath(), null, "Cannot list directory!");
        if (!srcArchived && dstArchived) {
            // Create sorted entries if copying an ordinary directory to a
            // new archive.
            // This is a courtesy only, so natural order is sufficient.
            Arrays.sort(members);
        }
        for (final String member : members)
            cp_r0(  preserve,
                    new TFile(src, member, srcDetector),
                    new TFile(dst, member, dstDetector),
                    srcDetector, dstDetector);
        if (preserve && !srcIsGhost)
            if (!dst.setLastModified(srcLastModified))
                throw new FileSystemException(dst.getPath(), null, "Cannot set last modification time!");
    } else if (src.isFile()) {
        if (dst.exists() && !dst.isFile())
            throw new FileSystemException(dst.getPath(), null, "Not a file!");
        cp0(preserve, src, dst);
    } else if (src.exists()) {
        throw new FileSystemException(src.getPath(), null, "Cannot copy special file!");
    } else {
        throw new NoSuchFileException(src.getPath());
    }
}
项目:dcmrs-broker    文件:Main.java   
/**
 * @param args the command line arguments
 * @throws java.io.FileNotFoundException
 * @throws java.nio.file.NotDirectoryException
 */
public static void main(String[] args) throws FileNotFoundException, NotDirectoryException
{
    Environment.getProperties();

    Router router = new Router();
    router.init();  
}
项目:jobson    文件:FilesystemJobSpecDAO.java   
public FilesystemJobSpecDAO(Path jobSpecsDir) throws IOException {
    requireNonNull(jobSpecsDir);
    if (!jobSpecsDir.toFile().exists())
        throw new FileNotFoundException(jobSpecsDir.toString() + ": No such directory");
    if (!jobSpecsDir.toFile().isDirectory())
        throw new NotDirectoryException(jobSpecsDir.toString() + ": Is not a directory");

    this.jobSpecsDir = jobSpecsDir;
}
项目: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());
}
项目:OpenJSharp    文件:ZipDirectoryStream.java   
ZipDirectoryStream(ZipPath zipPath,
                   DirectoryStream.Filter<? super java.nio.file.Path> filter)
    throws IOException
{
    this.zipfs = zipPath.getFileSystem();
    this.path = zipPath.getResolvedPath();
    this.filter = filter;
    // sanity check
    if (!zipfs.isDirectory(path))
        throw new NotDirectoryException(zipPath.toString());
}
项目:jdk8u-jdk    文件:ZipDirectoryStream.java   
ZipDirectoryStream(ZipPath zipPath,
                   DirectoryStream.Filter<? super java.nio.file.Path> filter)
    throws IOException
{
    this.zipfs = zipPath.getFileSystem();
    this.path = zipPath.getResolvedPath();
    this.filter = filter;
    // sanity check
    if (!zipfs.isDirectory(path))
        throw new NotDirectoryException(zipPath.toString());
}
项目:openjdk-jdk10    文件:JrtDirectoryStream.java   
JrtDirectoryStream(JrtPath dir,
        DirectoryStream.Filter<? super java.nio.file.Path> filter)
        throws IOException
{
    this.dir = dir;
    if (!dir.jrtfs.isDirectory(dir, true)) {  // sanity check
        throw new NotDirectoryException(dir.toString());
    }
    this.filter = filter;
}
项目:openjdk-jdk10    文件:PollingWatchService.java   
private PollingWatchKey doPrivilegedRegister(Path path,
                                             Set<? extends WatchEvent.Kind<?>> events,
                                             int sensitivityInSeconds)
    throws IOException
{
    // check file is a directory and get its file key if possible
    BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
    if (!attrs.isDirectory()) {
        throw new NotDirectoryException(path.toString());
    }
    Object fileKey = attrs.fileKey();
    if (fileKey == null)
        throw new AssertionError("File keys must be supported");

    // grab close lock to ensure that watch service cannot be closed
    synchronized (closeLock()) {
        if (!isOpen())
            throw new ClosedWatchServiceException();

        PollingWatchKey watchKey;
        synchronized (map) {
            watchKey = map.get(fileKey);
            if (watchKey == null) {
                // new registration
                watchKey = new PollingWatchKey(path, this, fileKey);
                map.put(fileKey, watchKey);
            } else {
                // update to existing registration
                watchKey.disable();
            }
        }
        watchKey.enable(events, sensitivityInSeconds);
        return watchKey;
    }

}
项目:openjdk-jdk10    文件:ZipDirectoryStream.java   
ZipDirectoryStream(ZipPath zipPath,
                   DirectoryStream.Filter<? super java.nio.file.Path> filter)
    throws IOException
{
    this.zipfs = zipPath.getFileSystem();
    this.path = zipPath.getResolvedPath();
    this.filter = filter;
    // sanity check
    if (!zipfs.isDirectory(path))
        throw new NotDirectoryException(zipPath.toString());
}
项目:AutomationFrameworkTPG    文件:TestBase.java   
@BeforeMethod(alwaysRun = true)
public void baseSetup(Method method, Object[] params) throws MalformedURLException, NoSuchFieldException, NotDirectoryException, JsonProcessingException {
    if (params.length > 0 && params[0] instanceof WebDriverInstance){
        webDriverInstance = (WebDriverInstance)params[0];
    }
    String tag = UUID.randomUUID().toString();
    logger.info("Tagging test thread with [{}]...", tag);
    ThreadContext.put(THREAD_TAG, tag);
    logTestSetup(method);
    logger.info("Base setup complete!");
}
项目:openjdk9    文件:JrtDirectoryStream.java   
JrtDirectoryStream(JrtPath dir,
        DirectoryStream.Filter<? super java.nio.file.Path> filter)
        throws IOException
{
    this.dir = dir;
    if (!dir.jrtfs.isDirectory(dir, true)) {  // sanity check
        throw new NotDirectoryException(dir.toString());
    }
    this.filter = filter;
}
项目:openjdk9    文件:ZipDirectoryStream.java   
ZipDirectoryStream(ZipPath zipPath,
                   DirectoryStream.Filter<? super java.nio.file.Path> filter)
    throws IOException
{
    this.zipfs = zipPath.getFileSystem();
    this.path = zipPath.getResolvedPath();
    this.filter = filter;
    // sanity check
    if (!zipfs.isDirectory(path))
        throw new NotDirectoryException(zipPath.toString());
}
项目:mycore    文件:MCRUploadServletDeployer.java   
private void checkTempStoragePath(String location) throws IOException {
    Path targetDir = Paths.get(location);
    if (!targetDir.isAbsolute()) {
        throw new MCRConfigurationException(
            "'" + MCR_FILE_UPLOAD_TEMP_STORAGE_PATH + "=" + location + "' must be an absolute path!");
    }
    if (Files.notExists(targetDir)) {
        LogManager.getLogger().info("Creating directory: {}", targetDir);
        Files.createDirectories(targetDir);
    }
    if (!Files.isDirectory(targetDir)) {
        throw new NotDirectoryException(targetDir.toString());
    }
}