java.nio.file.Files.isHidden()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中java.nio.file.Files.isHidden()方法的一些代码示例,展示了Files.isHidden()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Files.isHidden()方法的具体详情如下:
包路径:java.nio.file.Files
类名称:Files
方法名:isHidden

Files.isHidden介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private boolean isHidden(Path path) throws IOException {
  if (SystemUtils.IS_OS_WINDOWS) {
   try {
    DosFileAttributes dosFileAttributes = Files.readAttributes(path, DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
    return dosFileAttributes.isHidden();
   } catch (UnsupportedOperationException e) {
    return path.toFile().isHidden();
   }
  } else {
   return Files.isHidden(path);
  }
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
 if (!Files.isHidden(file)) {
  fileIndexer.indexFile(module, moduleExclusionFilters, moduleCoverageAndDuplicationExclusions, file, type, progressReport, exclusionCounter, ignoreCommand);
 }
 return FileVisitResult.CONTINUE;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * Creates a Swagger2MarkupConverter.Builder using a local Path.
 *
 * @param swaggerPath the local Path
 * @return a Swagger2MarkupConverter
 */
public static Builder from(Path swaggerPath) {
  Validate.notNull(swaggerPath, "swaggerPath must not be null");
  if (Files.notExists(swaggerPath)) {
    throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
  }
  try {
    if (Files.isHidden(swaggerPath)) {
      throw new IllegalArgumentException("swaggerPath must not be a hidden file");
    }
  } catch (IOException e) {
    throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
  }
  return new Builder(swaggerPath);
}

代码示例来源:origin: oracle/helidon

if (!Files.isRegularFile(path) || !Files.isReadable(path) || Files.isHidden(path)) {
  throw new HttpException("File is not accessible", Http.Status.FORBIDDEN_403);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * @param file
 * @return {@code true} if the given file is hidden
 * @throws IOException
 */
static boolean isHidden(File file) throws IOException {
  return Files.isHidden(toPath(file));
}

代码示例来源:origin: org.eclipse.jetty/jetty-util

public boolean isHidden(Path path)
{
  try
  {
    if (!path.startsWith(this.path))
      return true;
    for (int i=this.path.getNameCount(); i<path.getNameCount();i++)
    {
      if (path.getName(i).toString().startsWith("."))
      {
        return true;
      }
    }
    return Files.exists(path) && Files.isHidden(path);
  }
  catch (IOException e)
  {
    LOG.ignore(e);
    return false;
  }
}

代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core

protected boolean accept(Path path) {
  try {
    return !Files.isHidden(path);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: org.jline/jline

protected boolean accept(Path path) {
  try {
    return !Files.isHidden(path);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: apache/karaf

protected boolean accept(Path path) {
  try {
    return !Files.isHidden(path);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: apache/sis

/**
 * Invoked during iteration for omitting hidden files.
 */
@Override
public boolean accept(final Path entry) throws IOException {
  return !Files.isHidden(entry);
}

代码示例来源:origin: org.jline/jline

protected boolean accept(Path path) {
  try {
    return !Files.isHidden(path);
  } catch (IOException e) {
    return false;
  }
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

/**
 * @param file
 * @return {@code true} if the given file is hidden
 * @throws IOException
 */
static boolean isHidden(File file) throws IOException {
  return Files.isHidden(file.toPath());
}

代码示例来源:origin: 0c0c0f/security

public static boolean SecurityLFI(Path dir, Path file) throws Exception {
  try {
    if (!Files.exists(file.toAbsolutePath().normalize()) || Files.isHidden(file) || !file.toAbsolutePath().normalize().startsWith(dir.toAbsolutePath())) {
      return false;
    } else {
      return true;
    }
  } catch (Exception e) {
    throw new Exception("Down failure Problem during down files:" + e.getMessage());
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public boolean isHidden() {
  try {
    return Files.isHidden(toPath());
  }
  catch (IOException exception) {
    return false;
  }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-scanner-engine

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
 if (!Files.isHidden(file)) {
  fileIndexer.indexFile(module, moduleExclusionFilters, moduleCoverageAndDuplicationExclusions, file, type, progressReport, excludedByPatternsCount);
 }
 return FileVisitResult.CONTINUE;
}

代码示例来源:origin: org.wso2.carbon.uiserver/org.wso2.carbon.uiserver

private static boolean isValidAppArtifact(Path appPath) throws CarbonDeploymentException {
  try {
    return Files.exists(appPath) && Files.isDirectory(appPath) && Files.isReadable(appPath) &&
        !Files.isHidden(appPath);
  } catch (IOException e) {
    throw new CarbonDeploymentException("Cannot access web app artifact in '" + appPath + "'.", e);
  }
}

代码示例来源:origin: apache/karaf

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
  if (!Files.isHidden(file)) {
    Path r = dir.relativize(file);
    if (matcher.matches(r)) {
      stream.add(file);
    }
  }
  return FileVisitResult.CONTINUE;
}

代码示例来源:origin: SonarSource/sonarlint-cli

@Override
 public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
  if (Files.isHidden(dir)) {
   LOGGER.debug("Ignoring hidden directory: " + dir.toString());
   return FileVisitResult.SKIP_SUBTREE;
  }
  return super.preVisitDirectory(dir, attrs);
 }
}

代码示例来源:origin: com.powsybl/powsybl-afs-local

@Override
  public LocalFolder scanFolder(Path path, LocalFolderScannerContext context) {
    try {
      if (Files.isDirectory(path) && !Files.isHidden(path)) {
        return new DefaultLocalFolder(path, context.getRootDir(), context.getFileSystemName());
      }
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
    return null;
  }
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { Windows.class, DosAttributesT.class, Writable.class } )
public void testWindowsIsHidden() throws IOException {
  assertThat( Files.isHidden( fileTA() ) ).isFalse();
  Files.getFileAttributeView( absTA(), DosFileAttributeView.class ).setHidden( true );
  assertThat( Files.isHidden( fileTA() ) ).isTrue();
  Files.setAttribute( absTA(), "dos:hidden", false );
  assertThat( Files.isHidden( fileTA() ) ).isFalse();
}

相关文章

微信公众号

最新文章

更多