Class PathUtil

    • Constructor Detail

      • PathUtil

        public PathUtil()
    • Method Detail

      • getWindupUserDir

        public static Path getWindupUserDir()
        The path $USER_HOME/.windup
      • getWindupHome

        public static Path getWindupHome()
        The path $WINDUP_HOME (where Windup is installed.)
      • setWindupHome

        public static void setWindupHome​(Path windupHome)
      • getUserCacheDir

        public static Path getUserCacheDir()
        The path $USER_HOME/cache
      • getWindupCacheDir

        public static Path getWindupCacheDir()
        The path $WINDUP_HOME/cache
      • getUserIgnoreDir

        public static Path getUserIgnoreDir()
        The path $USER_HOME/ignore
      • getWindupIgnoreDir

        public static Path getWindupIgnoreDir()
        The path $WINDUP_HOME/ignore
      • getWindupAddonsDir

        public static Path getWindupAddonsDir()
        The path $WINDUP_HOME/addons
      • getUserRulesDir

        public static Path getUserRulesDir()
        The path $USER_HOME/rules
      • getUserLabelsDir

        public static Path getUserLabelsDir()
        The path $USER_HOME/labels
      • getWindupRulesDir

        public static Path getWindupRulesDir()
        The path $WINDUP_HOME/rules
      • getWindupLabelsDir

        public static Path getWindupLabelsDir()
        The path $WINDUP_HOME/labels
      • cleanFileName

        public static String cleanFileName​(String badFileName)
        Conservative approach to insuring that a given filename only contains characters that are legal for use in filenames on the disk. Other characters are replaced with underscore _ . Note that this should only be used with the filename itself, not the entire path, because it removes the '/' characters as well.
      • classFilePathToClassname

        public static String classFilePathToClassname​(String relativePath)
        Converts a path to a class file (like "foo/bar/My.class" or "foo\\bar\\My.class") to a fully qualified class name (like "foo.bar.My").
      • getRootFolderForSource

        public static Path getRootFolderForSource​(Path sourceFilePath,
                                                  String packageName)
        Returns the root path for this source file, based upon the package name.

        For example, if path is "/project/src/main/java/org/example/Foo.java" and the package is "org.example", then this should return "/project/src/main/java".

        Returns null if the folder structure does not match the package name.

      • isInSubDirectory

        public static boolean isInSubDirectory​(File dir,
                                               File file)
        Returns true if "file" is a subfile or subdirectory of "dir".

        For example with the directory /path/to/a, the following return values would occur:

        /path/to/a/foo.txt - true /path/to/a/bar/zoo/boo/team.txt - true /path/to/b/foo.txt - false

      • pathToPackageName

        public static String pathToPackageName​(String relativePath)
        Attempts to convert a path name (possibly a path within an archive) to a package name.
      • createDirectory

        public static void createDirectory​(Path dir,
                                           String dirDesc)
        Creates the given directory. Fails if it already exists.