jp.mwsoft.commonsfile

CommonsFilenameUtils

trait CommonsFilenameUtils extends AnyRef

Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. CommonsFilenameUtils
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. val that : File

    Attributes
    protected abstract

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  7. def baseName : String

    Gets the base name, minus the full path and extension, from a full filename.

    Gets the base name, minus the full path and extension, from a full filename.

    This method will handle a file in either Unix or Windows format. The text after the last forward or backslash and before the last dot is returned.

    a/b/c.txt --> c
    a.txt     --> a
    a/b/c     --> c
    a/b/c/    --> ""
    

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the name of the file without the path, or an empty string if none exists

  8. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  9. def concatPath (fullFilenameToAdd: File): String

    Concatenates a filename to a base path using normal command line style rules.

    Concatenates a filename to a base path using normal command line style rules.

    The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.

    The first argument is the base path, the second is the path to concatenate. The returned path is always normalized via #normalize(String), thus .. is handled.

    If pathToAdd is absolute (has an absolute prefix), then it will be normalized and returned. Otherwise, the paths will be joined, normalized and returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo/ + bar          -->   /foo/bar
    /foo + bar           -->   /foo/bar
    /foo + /bar          -->   /bar
    /foo + C:/bar        -->   C:/bar
    /foo + C:bar         -->   C:bar (*)
    /foo/a/ + ../bar     -->   foo/bar
    /foo/ + ../../bar    -->   null
    /foo/ + /bar         -->   /bar
    /foo/.. + /bar       -->   /bar
    /foo + bar/c.txt     -->   /foo/bar/c.txt
    /foo/c.txt + bar     -->   /foo/c.txt/bar (!)
    
    (*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use #getFullPath(String) on the base path argument.

    fullFilenameToAdd

    the filename (or path) to attach to the base

    returns

    the concatenated path, or null if invalid

  10. def concatPath (fullFilenameToAdd: String): String

    Concatenates a filename to a base path using normal command line style rules.

    Concatenates a filename to a base path using normal command line style rules.

    The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.

    The first argument is the base path, the second is the path to concatenate. The returned path is always normalized via #normalize(String), thus .. is handled.

    If pathToAdd is absolute (has an absolute prefix), then it will be normalized and returned. Otherwise, the paths will be joined, normalized and returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo/ + bar          -->   /foo/bar
    /foo + bar           -->   /foo/bar
    /foo + /bar          -->   /bar
    /foo + C:/bar        -->   C:/bar
    /foo + C:bar         -->   C:bar (*)
    /foo/a/ + ../bar     -->   foo/bar
    /foo/ + ../../bar    -->   null
    /foo/ + /bar         -->   /bar
    /foo/.. + /bar       -->   /bar
    /foo + bar/c.txt     -->   /foo/bar/c.txt
    /foo/c.txt + bar     -->   /foo/c.txt/bar (!)
    
    (*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use #getFullPath(String) on the base path argument.

    fullFilenameToAdd

    the filename (or path) to attach to the base

    returns

    the concatenated path, or null if invalid

  11. def concatPathFile (fullFilenameToAdd: String): File

    Concatenates a filename to a base path using normal command line style rules.

    Concatenates a filename to a base path using normal command line style rules.

    The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.

    The first argument is the base path, the second is the path to concatenate. The returned path is always normalized via #normalize(String), thus .. is handled.

    If pathToAdd is absolute (has an absolute prefix), then it will be normalized and returned. Otherwise, the paths will be joined, normalized and returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo/ + bar          -->   /foo/bar
    /foo + bar           -->   /foo/bar
    /foo + /bar          -->   /bar
    /foo + C:/bar        -->   C:/bar
    /foo + C:bar         -->   C:bar (*)
    /foo/a/ + ../bar     -->   foo/bar
    /foo/ + ../../bar    -->   null
    /foo/ + /bar         -->   /bar
    /foo/.. + /bar       -->   /bar
    /foo + bar/c.txt     -->   /foo/bar/c.txt
    /foo/c.txt + bar     -->   /foo/c.txt/bar (!)
    
    (*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use #getFullPath(String) on the base path argument.

    fullFilenameToAdd

    the filename (or path) to attach to the base

    returns

    the concatenated path, or null if invalid

  12. def concatPathFile (fullFilenameToAdd: File): File

    Concatenates a filename to a base path using normal command line style rules.

    Concatenates a filename to a base path using normal command line style rules.

    The effect is equivalent to resultant directory after changing directory to the first argument, followed by changing directory to the second argument.

    The first argument is the base path, the second is the path to concatenate. The returned path is always normalized via #normalize(String), thus .. is handled.

    If pathToAdd is absolute (has an absolute prefix), then it will be normalized and returned. Otherwise, the paths will be joined, normalized and returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo/ + bar          -->   /foo/bar
    /foo + bar           -->   /foo/bar
    /foo + /bar          -->   /bar
    /foo + C:/bar        -->   C:/bar
    /foo + C:bar         -->   C:bar (*)
    /foo/a/ + ../bar     -->   foo/bar
    /foo/ + ../../bar    -->   null
    /foo/ + /bar         -->   /bar
    /foo/.. + /bar       -->   /bar
    /foo + bar/c.txt     -->   /foo/bar/c.txt
    /foo/c.txt + bar     -->   /foo/c.txt/bar (!)
    
    (*) Note that the Windows relative drive prefix is unreliable when used with this method. (!) Note that the first parameter must be a path. If it ends with a name, then the name will be built into the concatenated path. If this might be a problem, use #getFullPath(String) on the base path argument.

    fullFilenameToAdd

    the filename (or path) to attach to the base

    returns

    the concatenated path, or null if invalid

  13. def dirPath : String

    Gets the full path from a full filename, which is the prefix + path.

    Gets the full path from a full filename, which is the prefix + path.

    This method will handle a file in either Unix or Windows format. The method is entirely text based, and returns the text before and including the last forward or backslash.

    C:\a\b\c.txt --> C:\a\b\
    ~/a/b/c.txt  --> ~/a/b/
    a.txt        --> ""
    a/b/c        --> a/b/
    a/b/c/       --> a/b/c/
    C:           --> C:
    C:\          --> C:\
    ~            --> ~/
    ~/           --> ~/
    ~user        --> ~user/
    ~user/       --> ~user/
    

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the path of the file, an empty string if none exists, null if invalid

  14. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  15. def equalPath (file: File, normalized: Boolean, caseSensitivity: IOCase = IOCase.SYSTEM): Boolean

    Checks whether two filenames are equal, optionally normalizing and providing control over the case-sensitivity.

    Checks whether two filenames are equal, optionally normalizing and providing control over the case-sensitivity.

    file

    the second filename to query, may be null

    normalized

    whether to normalize the filenames

    caseSensitivity

    what case sensitivity rule to use, null means case-sensitive

    returns

    true if the filenames are equal, null equals null

  16. def equalPath (file: String): Boolean

    Checks whether two filenames are equal after both have been normalized and using the case rules of the system.

    Checks whether two filenames are equal after both have been normalized and using the case rules of the system.

    Both filenames are first passed to #normalize(String). The check is then performed case-sensitive on Unix and case-insensitive on Windows.

    file

    the second filename to query, may be null

    returns

    true if the filenames are equal, null equals null

  17. def equalPath (file: File): Boolean

    Checks whether two filenames are equal after both have been normalized and using the case rules of the system.

    Checks whether two filenames are equal after both have been normalized and using the case rules of the system.

    Both filenames are first passed to #normalize(String). The check is then performed case-sensitive on Unix and case-insensitive on Windows.

    file

    the second filename to query, may be null

    returns

    true if the filenames are equal, null equals null

  18. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  19. def extension : String

    Gets the extension of a filename.

    Gets the extension of a filename.

    This method returns the textual part of the filename after the last dot. There must be no directory separator after the dot.

    foo.txt      --> "txt"
    a/b/c.jpg    --> "jpg"
    a/b.txt/c    --> ""
    a/b/c        --> ""
    

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the extension of the file or an empty string if none exists or null if the filename is null.

  20. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  21. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  22. def getPrefix : String

    Gets the prefix from a full filename, such as C:/ or ~/.

    Gets the prefix from a full filename, such as C:/ or ~/.

    This method will handle a file in either Unix or Windows format. The prefix includes the first slash in the full filename where applicable.

    Windows:
    a\b\c.txt           --> ""          --> relative
    \a\b\c.txt          --> "\"         --> current drive absolute
    C:a\b\c.txt         --> "C:"        --> drive relative
    C:\a\b\c.txt        --> "C:\"       --> absolute
    \\server\a\b\c.txt  --> "\\server\" --> UNC
    
    Unix:
    a/b/c.txt           --> ""          --> relative
    /a/b/c.txt          --> "/"         --> absolute
    ~/a/b/c.txt         --> "~/"        --> current user
    ~                   --> "~/"        --> current user (slash added)
    ~user/a/b/c.txt     --> "~user/"    --> named user
    ~user               --> "~user/"    --> named user (slash added)
    

    The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless.

    returns

    the prefix of the file, null if invalid

  23. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  24. def indexOfExtension : Int

    Returns the index of the last extension separator character, which is a dot.

    Returns the index of the last extension separator character, which is a dot.

    This method also checks that there is no directory separator after the last dot. To do this it uses #indexOfLastSeparator(String) which will handle a file in either Unix or Windows format.

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the index of the last separator character, or -1 if there is no such character

  25. def indexOfLastSeparator : Int

    Returns the index of the last directory separator character.

    Returns the index of the last directory separator character.

    This method will handle a file in either Unix or Windows format. The position of the last forward or backslash is returned.

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the index of the last separator character, or -1 if there is no such character

  26. def isExtension (extensions: Seq[String]): Boolean

    Checks whether the extension of the filename is one of those specified.

    Checks whether the extension of the filename is one of those specified.

    This method obtains the extension as the textual part of the filename after the last dot. There must be no directory separator after the dot. The extension check is case-sensitive on all platforms.

    extensions

    the extensions to check for, null checks for no extension

    returns

    true if the filename is one of the extensions

  27. def isExtension (extension: String): Boolean

    Checks whether the extension of the filename is that specified.

    Checks whether the extension of the filename is that specified.

    This method obtains the extension as the textual part of the filename after the last dot. There must be no directory separator after the dot. The extension check is case-sensitive on all platforms.

    extension

    the extension to check for, null or empty checks for no extension

    returns

    true if the filename has the specified extension

  28. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  29. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  30. def normalizePath : String

    Normalizes a path, removing double and single dot path steps.

    Normalizes a path, removing double and single dot path steps.

    This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified.

    A trailing slash will be retained. A double slash will be merged to a single slash (but UNC names are handled). A single dot path segment will be removed. A double dot will cause that path segment and the one before to be removed. If the double dot has no parent path segment to work with, null is returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo//               -->   /foo/
    /foo/./              -->   /foo/
    /foo/../bar          -->   /bar
    /foo/../bar/         -->   /bar/
    /foo/../bar/../baz   -->   /baz
    //foo//./bar         -->   /foo/bar
    /../                 -->   null
    ../foo               -->   null
    foo/bar/..           -->   foo/
    foo/../../bar        -->   null
    foo/../bar           -->   bar
    //server/foo/../bar  -->   //server/bar
    //server/../bar      -->   null
    C:\foo\..\bar        -->   C:\bar
    C:\..\bar            -->   null
    ~/foo/../bar/        -->   ~/bar/
    ~/../bar             -->   null
    
    The output will be the same on both Unix and Windows including the separator character.

    returns

    the normalized filename, or null if invalid

  31. def normalizePath (unixSeparator: Boolean): String

    Normalizes a path, removing double and single dot path steps.

    Normalizes a path, removing double and single dot path steps.

    This method normalizes a path to a standard format. The input may contain separators in either Unix or Windows format. The output will contain separators in the format specified.

    A trailing slash will be retained. A double slash will be merged to a single slash (but UNC names are handled). A single dot path segment will be removed. A double dot will cause that path segment and the one before to be removed. If the double dot has no parent path segment to work with, null is returned.

    The output will be the same on both Unix and Windows except for the separator character.

    /foo//               -->   /foo/
    /foo/./              -->   /foo/
    /foo/../bar          -->   /bar
    /foo/../bar/         -->   /bar/
    /foo/../bar/../baz   -->   /baz
    //foo//./bar         -->   /foo/bar
    /../                 -->   null
    ../foo               -->   null
    foo/bar/..           -->   foo/
    foo/../../bar        -->   null
    foo/../bar           -->   bar
    //server/foo/../bar  -->   //server/bar
    //server/../bar      -->   null
    C:\foo\..\bar        -->   C:\bar
    C:\..\bar            -->   null
    ~/foo/../bar/        -->   ~/bar/
    ~/../bar             -->   null
    
    The output will be the same on both Unix and Windows including the separator character.

    unixSeparator

    true if a unix separator should be used or false if a windows separator should be used.

    returns

    the normalized filename, or null if invalid

  32. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  33. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  34. def pathMatches (matcher: String, caseSensitivity: IOCase): Boolean

    Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.

    Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.

    The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not work properly at present in match strings.

    caseSensitivity

    what case sensitivity rule to use, null means case-sensitive

    returns

    true if the filename matches the wilcard string

  35. def pathMatches (matcher: String): Boolean

    Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.

    Checks a filename to see if it matches the specified wildcard matcher using the case rules of the system.

    The wildcard matcher uses the characters '?' and '*' to represent a single or multiple (zero or more) wildcard characters. This is the same as often found on Dos/Unix command lines. The check is case-sensitive on Unix and case-insensitive on Windows.

    wildcardMatch("c.txt", "*.txt")      --> true
    wildcardMatch("c.txt", "*.jpg")      --> false
    wildcardMatch("c.txt", "*.???")      --> true
    wildcardMatch("c.txt", "*.????")     --> false
    
    N.B. the sequence "*?" does not work properly at present in match strings.

    matcher

    the wildcard string to match against

    returns

    true if the filename matches the wilcard string

  36. def prefixLength : Int

    Returns the length of the filename prefix, such as C:/ or ~/.

    Returns the length of the filename prefix, such as C:/ or ~/.

    This method will handle a file in either Unix or Windows format.

    The prefix length includes the first slash in the full filename if applicable. Thus, it is possible that the length returned is greater than the length of the input string.

    Windows:
    a\b\c.txt           --> ""          --> relative
    \a\b\c.txt          --> "\"         --> current drive absolute
    C:a\b\c.txt         --> "C:"        --> drive relative
    C:\a\b\c.txt        --> "C:\"       --> absolute
    \\server\a\b\c.txt  --> "\\server\" --> UNC
    
    Unix:
    a/b/c.txt           --> ""          --> relative
    /a/b/c.txt          --> "/"         --> absolute
    ~/a/b/c.txt         --> "~/"        --> current user
    ~                   --> "~/"        --> current user (slash added)
    ~user/a/b/c.txt     --> "~user/"    --> named user
    ~user               --> "~user/"    --> named user (slash added)
    

    The output will be the same irrespective of the machine that the code is running on. ie. both Unix and Windows prefixes are matched regardless.

    returns

    the length of the prefix, -1 if invalid or null

  37. def removeExtensionPath : String

    Removes the extension from a filename.

    Removes the extension from a filename.

    This method returns the textual part of the filename before the last dot. There must be no directory separator after the dot.

    foo.txt    --> foo
    a\b\c.jpg  --> a\b\c
    a\b\c      --> a\b\c
    a.b\c      --> a.b\c
    

    The output will be the same irrespective of the machine that the code is running on.

    returns

    the filename minus the extension

  38. def separatorsToSystem : String

    Converts all separators to the Windows separator of backslash.

    Converts all separators to the Windows separator of backslash.

    returns

    the updated path

  39. def separatorsToUnix : String

    Converts all separators to the Unix separator of forward slash.

    Converts all separators to the Unix separator of forward slash.

    returns

    the updated path

  40. def separatorsToWindows : String

    Converts all separators to the Windows separator of backslash.

    Converts all separators to the Windows separator of backslash.

    returns

    the updated path

  41. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  42. def toString (): String

    Definition Classes
    AnyRef → Any
  43. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  44. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  45. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any