ur_rna.Utilities

## Class PathTools

- java.lang.Object
- - ur_rna.Utilities.PathTools

-     public final class PathTools
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PathTools.FileName`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static java.lang.String[]` | `defaultLocalSearchSubDirs`
    `private static java.lang.String[]` | `documentsDirs`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `PathTools()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `addSlash(java.lang.String path)`
    `static boolean` | `anyFilesMatch(java.lang.String dirPath, java.lang.String filter)` Returns the true if any files in the given directory match the specified filter, which should be a a glob expression such as "*.{java,class,jar}" Glob expressions are fairly uniform across platforms.
    `static java.lang.String` | `changeExtension(java.lang.String file, java.lang.String extension)`
    `static boolean` | `exists(java.lang.String fileOrDirectory)`
    `static java.io.File` | `fileFromPath(java.lang.String path)`
    `static java.io.File` | `fileFromPath(java.lang.String path, boolean mustExist)`
    `static java.io.File` | `findLocalPath(java.lang.Class refType, java.lang.String name, java.lang.String... trySubDirs)`
    `static java.io.File` | `findLocalPath(java.lang.String name)`
    `static java.lang.String` | `getAppPath(java.lang.Class referenceClass)` Gets the absolute path to the directory containing the class file for referenceClass.
    `static java.lang.String` | `getBaseName(java.lang.String fullName)` Gets the base name of the file -- i.e.
    `static java.lang.String` | `getBaseName(java.lang.String fullName, boolean allowMultiDotExtensions)` Gets the base name of the file -- i.e.
    `static java.lang.String` | `getCanonicalPath(java.io.File file)` Unlike the other getCanonicalPath overloads, this one simply uses `File.getCanonicalPath()`
    `static java.lang.String` | `getCanonicalPath(java.lang.String path)` Get the canonical form of a file-system path by: Converting it to unix format (if Windows) Replacing `//` with `/` Replacing `/./` with `/` Replacing `dirname/../` with `/`
    `static java.lang.String` | `getCanonicalPath(java.lang.String path, boolean addEndSlash, boolean removeEndSlash, boolean removeStartSlash, boolean removeDotSlashAtStart)` Get the canonical form of a file-system path by: Converting it to unix format (if Windows) Removing starting slashes (if `removeStartSlash` is true) Adding an ending slash (if `addEndSlash` is true} Removing an ending slash (if `removeEndSlash` is true Replacing `//` with `/` Replacing `/./` with `/` Replacing `dirname/../` with `/` Removing `./` at the start of a path (if `removeDotSlashAtStart` is true)
    `static java.lang.String` | `getDir(java.lang.String fullName)` Get the full parent directory path, including the final slash.
    `static java.lang.String` | `getDir(java.lang.String fullName, boolean includeFinalSlash)`
    `static java.io.File` | `getDocumentsDir()`
    `static java.lang.String` | `getExt(java.lang.String fullName)` Gets the extension of the file including the preceding dot (.) If the file name contains multiple dot (.) characters, the extension is defined as the segment starting with the final dot.
    `static java.lang.String` | `getExt(java.lang.String fullName, boolean includeDot, boolean allowMultiDotExtensions)` Gets the extension of the file including the preceding dot (.)
    `static java.io.File` | `getFirstExisting(java.io.File parentDir, boolean includeDirs, boolean includeFiles, java.lang.String... paths)`
    `static java.io.File` | `getHomeDir()`
    `static boolean` | `isDir(java.lang.String directory)`
    `static boolean` | `isFile(java.lang.String file)`
    `static java.util.List<java.io.File>` | `listFiles(java.lang.String dirPath, java.lang.String filter)` Lists all files in a directory that match the specified filter, which should be a a glob expression such as "*.{java,class,jar}" Glob expressions are fairly uniform across platforms.
    `static PathTools.FileName` | `parse(java.lang.String fullFilePath)`
    `static PathTools.FileName` | `parse(java.lang.String fullFilePath, boolean allowMultiDotExtensions)`
    `static boolean` | `verifyWritable(java.io.File file)` Verify that a directory is writeable by writing a new file (and then deleting it).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### defaultLocalSearchSubDirs

          private static java.lang.String[] defaultLocalSearchSubDirs

    - #### documentsDirs

          private static final java.lang.String[] documentsDirs

  - ### Constructor Detail

    - #### PathTools

          private PathTools()

  - ### Method Detail

    - #### addSlash

          public static java.lang.String addSlash(java.lang.String path)

    - #### anyFilesMatch

          public static boolean anyFilesMatch(java.lang.String dirPath,
                                              @NotNull
                                              java.lang.String filter)

      Returns the true if any files in the given directory match the specified filter, which should be a a glob expression such as "*.{java,class,jar}" Glob expressions are fairly uniform across platforms. See `PathMatcher` for glob details.
      Parameters:
        `dirPath` - The path of the directory to search.
        `filter` - The glob expression to match files against.
      Returns:
        True if at least one file in the directory matches the filter, or false otherwise.

    - #### changeExtension

          public static java.lang.String changeExtension(java.lang.String file,
                                                         java.lang.String extension)

    - #### exists

          public static boolean exists(java.lang.String fileOrDirectory)

    - #### fileFromPath

          public static java.io.File fileFromPath(java.lang.String path)

    - #### fileFromPath

          public static java.io.File fileFromPath(java.lang.String path,
                                                  boolean mustExist)

    - #### findLocalPath

          public static java.io.File findLocalPath(java.lang.Class refType,
                                                   java.lang.String name,
                                                   java.lang.String... trySubDirs)

    - #### findLocalPath

          public static java.io.File findLocalPath(java.lang.String name)

    - #### getAppPath

          @Nullable
          public static java.lang.String getAppPath(java.lang.Class referenceClass)

      Gets the absolute path to the directory containing the class file for referenceClass. For a jar'd application, this is the directory containing the Jar file in which referenceClass resides.
      Returns:
        The absolute path to the directory containing the referenceClass. The function returns `null` if security restrictions do not permit resolution of paths.

    - #### getBaseName

          public static java.lang.String getBaseName(java.lang.String fullName)

      Gets the base name of the file -- i.e. the name without extension. If the file name contains multiple dot (.) characters, the extension is defined as the segment starting with the final dot.
      Parameters:
        `fullName` - The full file name or path.
      Returns:
        The base name of the file -- i.e. the name without extension.
      See Also:
        `getBaseName(String, boolean)`

    - #### getBaseName

          public static java.lang.String getBaseName(java.lang.String fullName,
                                                     boolean allowMultiDotExtensions)

      Gets the base name of the file -- i.e. the name without extension.
      Parameters:
        `fullName` - The full file name or path.
        `allowMultiDotExtensions` - If true, the extension starts at the first dot (.) encountered, which means the resulting base name will never contain any dots. If false, the extension starts at the last dot, so the base name will contain all dots except the final one.
      Returns:
        The base name of the file -- i.e. the name without any extension.

    - #### getCanonicalPath

          public static java.lang.String getCanonicalPath(java.io.File file)

      Unlike the other getCanonicalPath overloads, this one simply uses `File.getCanonicalPath()`

    - #### getCanonicalPath

          public static java.lang.String getCanonicalPath(java.lang.String path)

      Get the canonical form of a file-system path by:
      1. Converting it to unix format (if Windows)
      2. Replacing `//` with `/`
      3. Replacing `/./` with `/`
      4. Replacing `dirname/../` with `/`
      Parameters:
        `path` - The path to canonicalize
      Returns:
        A canonical unix-style form of the path
      See Also:
        `getCanonicalPath(String, boolean, boolean, boolean, boolean)`

    - #### getCanonicalPath

          public static java.lang.String getCanonicalPath(java.lang.String path,
                                                          boolean addEndSlash,
                                                          boolean removeEndSlash,
                                                          boolean removeStartSlash,
                                                          boolean removeDotSlashAtStart)

      Get the canonical form of a file-system path by:
      1. Converting it to unix format (if Windows)
      2. Removing starting slashes (if `removeStartSlash` is true)
      3. Adding an ending slash (if `addEndSlash` is true}
      4. Removing an ending slash (if `removeEndSlash` is true
      5. Replacing `//` with `/`
      6. Replacing `/./` with `/`
      7. Replacing `dirname/../` with `/`
      8. Removing `./` at the start of a path (if `removeDotSlashAtStart` is true)
      Parameters:
        `path` - The path to canonicalize
        `addEndSlash` - If true, any slashes at the end of the path will be removed. i.e. `path/` becomes `path`
        `removeEndSlash` - If true any path not ending with a slash will have one appended. i.e. `path` becomes `path/`
        `removeStartSlash` - If true, any slashes at the beginning of the path will be removed. i.e. `/path` becomes `path`
        `removeDotSlashAtStart` - If this is true and the path starts with `./`, it will be removed. i.e. `./path` becomes `path`
      Returns:
        A canonical unix-style form of the path

    - #### getDir

          public static java.lang.String getDir(java.lang.String fullName)

      Get the full parent directory path, including the final slash.

      Examples:
      /path/to/fileName.ext | `-->` | /path/to/
      /fileName.ext | `-->` | /
      C:\Windows\System32 | `-->` | C:\Windows\
      images\banana.jpg | `-->` | images\
      HelloWorld.txt | `-->` | (empty)

      Parameters:
        `fullName` - The full path to the file.
      Returns:
        The full parent directory path, including the final slash, or an empty string if the full path does not contain a directory separator character `\` or `/`.

    - #### getDir

          public static java.lang.String getDir(java.lang.String fullName,
                                                boolean includeFinalSlash)

    - #### getDocumentsDir

          public static java.io.File getDocumentsDir()

    - #### getExt

          public static java.lang.String getExt(java.lang.String fullName)

      Gets the extension of the file including the preceding dot (.) If the file name contains multiple dot (.) characters, the extension is defined as the segment starting with the final dot.
      Parameters:
        `fullName` - The full file name or path.
      Returns:
        The extension of the file including the preceding dot (.)

    - #### getExt

          public static java.lang.String getExt(java.lang.String fullName,
                                                boolean includeDot,
                                                boolean allowMultiDotExtensions)

      Gets the extension of the file including the preceding dot (.)
      Parameters:
        `fullName` - The full file name or path.
        `includeDot` -
        `allowMultiDotExtensions` - If true, the extension starts at the first dot (.) encountered in the file name, which means the resulting extension may contain more than one dot. If false, the extension starts at the last dot, so the extension will either be empty (if the file has no extension) or it will contain exactly one dot as its first character. @return The extension of the file including the preceding dot (.)

    - #### getFirstExisting

          @Nullable
          public static java.io.File getFirstExisting(@Nullable
                                                                 java.io.File parentDir,
                                                                 boolean includeDirs,
                                                                 boolean includeFiles,
                                                                 java.lang.String... paths)

    - #### getHomeDir

          public static java.io.File getHomeDir()

    - #### isDir

          public static boolean isDir(java.lang.String directory)

    - #### isFile

          public static boolean isFile(java.lang.String file)

    - #### listFiles

          public static java.util.List<java.io.File> listFiles(java.lang.String dirPath,
                                                               @NotNull
                                                               java.lang.String filter)

      Lists all files in a directory that match the specified filter, which should be a a glob expression such as "*.{java,class,jar}" Glob expressions are fairly uniform across platforms. See `PathMatcher` for glob details.
      Parameters:
        `dirPath` - The path of the directory to search.
        `filter` - The glob expression to match files against.
      Returns:
        A list of Files that match the filter.

    - #### parse

          public static PathTools.FileName parse(java.lang.String fullFilePath)

    - #### parse

          public static PathTools.FileName parse(java.lang.String fullFilePath,
                                                 boolean allowMultiDotExtensions)

    - #### verifyWritable

          public static boolean verifyWritable(java.io.File file)

      Verify that a directory is writeable by writing a new file (and then deleting it). If the file represents an existing file, the return value will be file.canWrite() If the file does not exist, the return value is false.
      Parameters:
        `file` - the file or directory to test for writing