java.lang.Object
com.github.blutorange.maven.plugin.closurecompiler.common.FileHelper

public class FileHelper extends Object
Helper methods for working with files.
  • Method Details

    • relativizePath

      public static String relativizePath(File base, File target)
      Returns:
      The path of the given target, relative to the specified base file.
    • relativizeRelativePath

      public static String relativizeRelativePath(File base, File target)
      Makes target relative to base. Allows base and target to be relative paths.
      Returns:
      The path of the given target, relative to the specified base file.
    • getFile

      public static File getFile(File directory, String... names)
      Sames as FileUtils.getFile(File, String...), but ignores empty names.
    • getAbsoluteFile

      public static File getAbsoluteFile(File basedir, File... files)
      If the last file does not refer to an absolute path, return the file relative to the given base directories. If the last file already refers to an absolute path, return the last file.
      Parameters:
      basedir - Directory relative to which to resolve relative files.
      files - Files to make absolute.
    • getAbsoluteFile

      public static File getAbsoluteFile(File basedir, String... files)
      If the last file does not refer to an absolute path, return the file relative to the given base directories. If the last file already refers to an absolute path, return the last file.
      Parameters:
      basedir - Directory relative to which to resolve relative files.
      files - Files to make absolute.
    • getIncludedFiles

      public static List<File> getIncludedFiles(File baseDir, List<String> includes, List<String> excludes)
      Processes the includes and excludes relative to the given base directory, and returns all included files.
      Parameters:
      baseDir - Base directory of the includes and excludes.
      includes - List of specified includes
      excludes - List of specified excludes
      Returns:
      A list of all files matching the given includes and excludes.
    • absoluteFileToCanonicalFile

      public static File absoluteFileToCanonicalFile(File file)
      When the file is an absolute path, return its canonical representation, if possible.
      Parameters:
      file - The file to process.
      Returns:
      The canonical path of the file, if absolute, or the file itself otherwise.
    • startsWithBom

      public static boolean startsWithBom(File file, Charset encoding) throws IOException
      Throws:
      IOException