All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.shiftleft.x2cpg.SourceFiles.scala Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package io.shiftleft.x2cpg

import better.files._

object SourceFiles {

  /**
    * For a given array of input paths, determine all
    * source files by inspecting filename extensions.
    * */
  def determine(inputPaths: Set[String], sourceFileExtensions: Set[String]): List[String] = {
    def hasSourceFileExtension(file: File): Boolean =
      file.extension.exists(sourceFileExtensions.contains)

    val (dirs, files) = inputPaths
      .map(File(_))
      .partition(_.isDirectory)

    val matchingFiles = files.filter(hasSourceFileExtension).map(_.toString)
    val matchingFilesFromDirs = dirs
      .flatMap(_.listRecursively.filter(hasSourceFileExtension))
      .map(_.toString)

    (matchingFiles ++ matchingFilesFromDirs).toList.sorted
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy