com.sap.psr.vulas.shared.util.FileUtil.hasFileExtension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(161)

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

FileUtil.hasFileExtension介绍

[英]Checks whether the given Path points to a file that has one of the given file extensions.
[中]检查给定路径是否指向具有给定文件扩展名之一的文件。

代码示例

代码示例来源:origin: SAP/vulnerability-assessment-tool

@Override
  public FileVisitResult visitFile(Path _f, BasicFileAttributes attrs) {
    if(!this.foundFile(_f) && FileUtil.hasFileExtension(_f, this.suffixes))
      this.addFile(_f);
    return FileVisitResult.CONTINUE;
  }
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Creates a {@link PythonId} of type {@link ConstructType#MODU} for the given py file.
 */
public static PythonId getModule(File _file) throws IllegalArgumentException {
  if(!FileUtil.hasFileExtension(_file.toPath(), new String[] { "py" })) {
    throw new IllegalArgumentException("Expected file with file extension [py], got [" + _file.toString() + "]");
  }
  final Path p = _file.toPath().toAbsolutePath();
  // Add file name w/o extension to qname components
  final String module_name = FileUtil.getFileName(p.toString(), false);
  // Search upwards until there's no __init__.py anymore, and add directory names to the qname components
  final List<String> package_name = new ArrayList<String>();
  Path search_path = p.getParent();
  while(DirUtil.containsFile(search_path.toFile(), "__init__.py") && search_path.getNameCount() > 1) {
    package_name.add(0, search_path.getFileName().toString());
    search_path = search_path.getParent();
  }
  // Create the package (if any), the module and return the latter
  PythonId pack = null;
  if(!package_name.isEmpty())
    pack = new PythonId(null, PythonId.Type.PACKAGE, StringUtil.join(package_name, "."));
  return new PythonId(pack, PythonId.Type.MODULE, module_name);
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

try {
  if(FileUtil.isAccessibleDirectory(p) || FileUtil.hasFileExtension(p, EXT_FILTER)) {
    log.info("Searching for Python constructs in search path [" + p + "] with filter [" + StringUtil.join(EXT_FILTER, ", ") + "]");
    final FileAnalyzer da = FileAnalyzerFactory.buildFileAnalyzer(p.toFile(), EXT_FILTER);

相关文章