Packages

  • package root
    Definition Classes
    root
  • package grizzled

    The Grizzled Scala Library contains a variety of miscellaneous, general purpose utility classes and objects.

    The Grizzled Scala Library contains a variety of miscellaneous, general purpose utility classes and objects.

    The home page for the Grizzled Scala Library is http://software.clapper.org/grizzled-scala/. Please see that page for complete details, including installation instructions.

    Definition Classes
    root
  • package file

    File-related classes and utilities.

    File-related classes and utilities. This package is distinguished from the grizzled.io package in that this package operates on files and paths, not on open streams or sources.

    Definition Classes
    grizzled
    See also

    grizzled.io

  • package filter

    Contains various file- and I/O-related filter classes.

    Contains various file- and I/O-related filter classes.

    Definition Classes
    file
  • FileDoesNotExistException
  • Implicits
  • Includer
  • util

object util

Useful file-related utility functions.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. util
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def basename(path: String, fileSep: String = fileSeparator): String

    Get the basename (file name only) part of a path.

    Get the basename (file name only) part of a path.

    path

    the path (absolute or relative)

    fileSep

    the file separator to use. Defaults to the value of the "file.separator" property.

    returns

    the file name portion

  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. def copy(file: String, targetDir: String): Try[Boolean]

    Copy a file to a directory.

    Copy a file to a directory. If the target directory does not exist, it is created. The JDK's java.nio.file.Files.copy() function provides a similar capability.

    file

    Path name of the file to copy

    targetDir

    Path name to target directory

    returns

    Success(true) if the copy worked. Failure(exception) on error.

  8. def copy(file: String, targetDir: String, createTarget: Boolean): Try[Boolean]

    Copy a file to a directory.

    Copy a file to a directory. The JDK's java.nio.file.Files.copy() function provides a similar capability.

    file

    Path name of the file to copy

    targetDir

    Path name to target directory

    createTarget

    true to create the target directory, false to throw an exception if the directory doesn't already exist.

    returns

    Success(true) if the copy worked. Failure(exception) on error.

  9. def copy(files: Iterable[String], targetDir: String, createTarget: Boolean = true): Try[Boolean]

    Copy multiple files to a target directory.

    Copy multiple files to a target directory. Also see the version of this method that takes only one file.

    files

    An Iterable of file names to be copied

    targetDir

    Path name to target directory

    createTarget

    true to create the target directory, false to throw an exception if the directory doesn't already exist.

    returns

    Success(true) if the copy worked. Failure(exception) on error.

    Annotations
    @SuppressWarnings()
  10. def copyFile(source: File, target: File): Try[File]

    Copy a source file to a target file, using binary copying.

    Copy a source file to a target file, using binary copying. The source file must be a file. The target path can be a file or a directory; if it is a directory, the target file will have the same base name as as the source file.

    The JDK's java.nio.file.Files.copy() function provides a similar capability.

    source

    path to the source file

    target

    path to the target file or directory

    returns

    A Success containing the full path of the target file, or Failure(exception)

  11. def copyFile(sourcePath: String, targetPath: String): Try[String]

    Copy a source file to a target file, using binary copying.

    Copy a source file to a target file, using binary copying. The source file must be a file. The target path can be a file or a directory; if it is a directory, the target file will have the same base name as as the source file.

    The JDK's java.nio.file.Files.copy() function provides a similar capability.

    sourcePath

    path to the source file

    targetPath

    path to the target file or directory

    returns

    A Success with the full path of the target file, or Failure(exception)

  12. def copyTree(sourceDir: File, targetDir: File): Try[Boolean]

    Recursively copy a source directory and its contents to a target directory.

    Recursively copy a source directory and its contents to a target directory. Creates the target directory if it does not exist.

    sourceDir

    the source directory

    targetDir

    the target directory

    returns

    Success(true) if the copy worked. Failure(exception) on error.

    Annotations
    @SuppressWarnings()
  13. def copyTree(sourceDir: String, targetDir: String): Try[Boolean]

    Recursively copy a source directory and its contents to a target directory.

    Recursively copy a source directory and its contents to a target directory. Creates the target directory if it does not exist.

    sourceDir

    the source directory

    targetDir

    the target directory

    returns

    Success(true) if the copy worked. Failure(exception) on error.

  14. def deleteTree(dir: File): Try[Int]

    Recursively remove a directory tree.

    Recursively remove a directory tree. This function is conceptually equivalent to rm -r on a Unix system.

    dir

    The directory

    returns

    Failure(exception) on error, Success(total) on success. total is the total number of deleted files.

  15. def deleteTree(dir: String): Unit

    Recursively remove a directory tree.

    Recursively remove a directory tree. This function is conceptually equivalent to rm -r on a Unix system.

    dir

    The directory

  16. def dirname(path: String, fileSep: String = fileSeparator): String

    Get the directory name of a pathname.

    Get the directory name of a pathname.

    path

    path (absolute or relative)

    fileSep

    the file separator to use. Defaults to the value of the "file.separator" property.

    returns

    the directory portion

  17. def dirnameBasename(path: String, fileSep: String = fileSeparator): (String, String)

    Split a path into directory (dirname) and file (basename) components.

    Split a path into directory (dirname) and file (basename) components. Analogous to Python's os.path.pathsplit() function.

    path

    the path to split

    fileSep

    the file separator to use. Defaults to the value of the "file.separator" property.

    returns

    a (dirname, basename) tuple of strings

  18. def dirnameBasenameExtension(pathname: String, fileSep: String = fileSeparator): (String, String, String)

    Split a pathname into the directory name, basename, and extension pieces.

    Split a pathname into the directory name, basename, and extension pieces.

    pathname

    the pathname

    fileSep

    the file separator to use. Defaults to the value of the "file.separator" property.

    returns

    a 3-tuple of (dirname, basename, extension)

  19. def eglob(pattern: String): List[String]

    An extended glob function that supports all the wildcards of the glob() function, in addition to:

    An extended glob function that supports all the wildcards of the glob() function, in addition to:

    • a leading ~, signifying the user's home directory
    • a special ** wildcard that recursively matches any directory. (Think "ant".)

    ~user is not supported, however.

    NOTE: Any non-Windows operating system is treated as Posix.

    pattern

    the wildcard pattern

    returns

    list of matches, or an empty list for none

  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  22. val fileSeparator: String
  23. val fileSeparatorChar: Char
  24. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  25. def fnmatch(name: String, pattern: String): Boolean

    Similar to Python's fnmatch() function, this function determines whether a string matches a wildcard pattern.

    Similar to Python's fnmatch() function, this function determines whether a string matches a wildcard pattern. Patterns are Unix-style shell-style wildcards:

    • * matches everything
    • ? matches any single character
    • [set] matches any character in set
    • [!set] matches any character not in set

    An initial period in filename is not special. Matches are case-sensitive on Posix operating systems, case-insensitive elsewhere.

    name

    the name to match

    pattern

    the wildcard pattern

  26. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  27. def glob(path: String): List[String]

    Return a list of paths matching a pathname pattern.

    Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards. See fnmatch(). This function is essentially a direct port of the Python glob.glob() function.

    Restrictions:

    - There's currently no way to escape a wildcard character. That is, if you need to match a '*' character or a '?' character exactly, you can't do that with this library. (You can't do it with the glob library in Python 2 or Python 3, either.)

    path

    The path to expand.

    returns

    a list of possibly expanded file names

  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  30. def joinAndNormalizePath(pieces: File*): File

    Join components of a path together, using the current file separator; then, normalize the result.

    Join components of a path together, using the current file separator; then, normalize the result.

    pieces

    path pieces

    returns

    a composite, normalized path

    See also

    joinPath(pieces:String*):String*

    normalizePath

  31. def joinAndNormalizePath(pieces: String*): String

    Join components of a path together, using the current file separator; then, normalize the result.

    Join components of a path together, using the current file separator; then, normalize the result.

    pieces

    path pieces

    returns

    a composite, normalized path

    See also

    joinPath(pieces:String*):String*

    normalizePath

  32. def joinPath(pieces: File*): File

    Join components of a path together, using the current file separator.

    Join components of a path together, using the current file separator.

    pieces

    path pieces

    returns

    a composite path

  33. def joinPath(pieces: String*): String

    Join components of a path together, using the current file separator.

    Join components of a path together, using the current file separator.

    pieces

    path pieces

    returns

    a composite path

  34. def joinPath(fileSep: String, pieces: Seq[String]): String

    Join components of a path together, using the specified file separator.

    Join components of a path together, using the specified file separator.

    fileSep

    the file separator to use

    pieces

    path pieces

    returns

    a composite path

  35. def listRecursively(file: File, topdown: Boolean = true): LazyList[File]

    List a directory recursively, returning File objects for each file (and subdirectory) found.

    List a directory recursively, returning File objects for each file (and subdirectory) found. This method does lazy evaluation, instead of calculating everything up-front, as walk() does.

    The JDK's java.nio.file.Files.walk() function provides a similar capability in JDK 8. Prior to JDK 8, you can also use java.nio.file.Files.walkFileTree()

    file

    The File object, presumed to represent a directory.

    topdown

    If true (the default), the stream will be generated top down. If false, it'll be generated bottom-up.

    returns

    a stream of File objects.

  36. def longestCommonPathPrefix(paths: List[String]): String

    Find the longest common path prefix from a list of paths.

    Find the longest common path prefix from a list of paths. Based on https://rosettacode.org/wiki/Find_common_directory_path#Advanced

    paths

    the paths

    returns

    the longest common path, which might be the empty string

    Annotations
    @SuppressWarnings()
  37. def makeTemporaryDirectory(prefix: String, maxTries: Int = 3): Try[File]

    Create a temporary directory.

    Create a temporary directory.

    prefix

    Prefix for directory name

    maxTries

    Maximum number of times to try creating the directory before giving up.

    returns

    A Success of the directory, or a Failure with any error that occurs.

  38. def nativePath(path: String): String

    Converts a path name from universal path notation to the operating system-specific format.

    Converts a path name from universal path notation to the operating system-specific format. Universal path notation always uses a Unix-style "/" to separate path elements. A native path can be converted to a universal path via the universal_path() function. Note that on POSIX-compliant systems, this function simply returns the path parameter unmodified.

    path

    the path to convert from universtal to native path notation

    returns

    the native path

  39. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  40. def normalizePath(path: String): String

    Normalize a path, eliminating double slashes, resolving embedded ".." strings (e.g., "/foo/../bar" becomes "/bar"), etc.

    Normalize a path, eliminating double slashes, resolving embedded ".." strings (e.g., "/foo/../bar" becomes "/bar"), etc. Works for Windows and Posix operating systems.

    path

    the path

    returns

    the normalized path

  41. def normalizePosixPath(path: String): String

    Adapted from the Python version of normpath() in Python's os.posixpath module.

    Adapted from the Python version of normpath() in Python's os.posixpath module.

    path

    the path

    returns

    the normalized path

  42. def normalizeWindowsPath(path: String): String

    Normalize a Windows path name.

    Normalize a Windows path name. Handles UNC paths. Adapted from the Python version of normpath() in Python's os.ntpath module.

    path

    the path

    returns

    the normalized path

  43. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  44. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  45. def pwd: String

    Return the current working directory, as an absolute path.

    Return the current working directory, as an absolute path.

    returns

    the current working directory

  46. def relativePath(from: File, to: File): String

    Calculate the relative path between two files.

    Calculate the relative path between two files.

    from

    the starting file

    to

    the file to be converted to a relative path

    returns

    the (String) relative path

  47. def splitDrivePath(path: String): (String, String)

    Split a Windows-style path into drive name and path portions.

    Split a Windows-style path into drive name and path portions.

    path

    the path

    returns

    a (drive, path) tuple, either component of which can be * an empty string

  48. def splitPath(path: String, fileSep: String = fileSeparator): List[String]

    Split a path into its constituent components.

    Split a path into its constituent components. If the path is absolute, the first piece will have a file separator in the beginning. Examples:

    Input Output
    "" List("")
    "/" List("/")
    "foo" List("foo")
    "foo/bar" List("foo", "bar")
    "." List(".")
    "../foo" List("..", "foo")
    "./foo" List(".", "foo")
    "/foo/bar/baz" List("/foo", "bar", "baz")
    "foo/bar/baz" List("foo", "bar", "baz")
    "/foo" List("/foo")

    path

    the path

    fileSep

    the file separator to use. Defaults to the value of the "file.separator" property.

    returns

    the component pieces.

  49. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  50. def temporaryDirectory: File

    Determine the temporary directory to use.

    Determine the temporary directory to use.

    returns

    the temporary directory

  51. def toString(): String
    Definition Classes
    AnyRef → Any
  52. def touch(path: String, time: Long = -1): Try[Boolean]

    Similar to the Unix touch command, this function:

    Similar to the Unix touch command, this function:

    • updates the access and modification times for a file
    • creates the file if it does not exist

    If the file is a directory, this method will return an error.

    path

    The file to touch

    time

    Set the last-modified time to this time, or to the current time if this parameter is negative.

    returns

    Failure(exception) on error, Success(true) on success

  53. def touchMany(files: Iterable[String], time: Long = -1): Try[Int]

    Similar to the Unix touch command, this function:

    Similar to the Unix touch command, this function:

    • updates the access and modification times for any existing files in a list of files
    • creates an nonexistent files in the list

    If any file in the list is a directory, this method will return an error.

    files

    Iterable of files to touch

    time

    Set the last-modified time to this time, or to the current time if this parameter is negative.

    returns

    Failure(exception) on error. Success(total) on success.

  54. def universalPath(path: String): String

    Converts a path name from its operating system-specific format to a universal path notation.

    Converts a path name from its operating system-specific format to a universal path notation. Universal path notation always uses a Unix-style "/" to separate path elements. A universal path can be converted to a native (operating system-specific) path via the native_path() function. Note that on POSIX-compliant systems, this function simply returns the path parameter unmodified.

    path

    the path to convert to universal path notation

    returns

    the universal path

  55. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  58. def walk(top: String, topdown: Boolean = true): List[(String, List[String], List[String])]

    Directory tree generator, adapted from Python's os.walk() function.

    Directory tree generator, adapted from Python's os.walk() function.

    For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), yields a 3-tuple

    (dirpath, dirnames, filenames)

    dirpath is a string, the path to the directory. dirnames is a list of the names of the subdirectories in dirpath (excluding '.' and '..'). filenames is a list of the names of the non-directory files in dirpath. Note that the names in the lists are just names, with no path components. To get a full path (which begins with top) to a file or directory in dirpath, use dirpath + java.io.fileSeparator + name, or use joinPath().

    If topdown is true, the triple for a directory is generated before the triples for any of its subdirectories (directories are generated top down). If topdown is false, the triple for a directory is generated after the triples for all of its subdirectories (directories are generated bottom up).

    WARNING! This method does not grok symbolic links!

    The JDK's java.nio.file.Files.walk() function provides a similar capability in JDK 8. Prior to JDK 8, you can also use java.nio.file.Files.walkFileTree()

    top

    name of starting directory

    topdown

    true to do a top-down traversal, false otherwise.

    returns

    List of triplets, as described above.

  59. def withTemporaryDirectory[T](prefix: String)(action: (File) ⇒ T): T

    Allow execution of a block of code within the context of a temporary directory.

    Allow execution of a block of code within the context of a temporary directory. The temporary directory is cleaned up after the operation completes.

    prefix

    file name prefix to use

    action

    action to perform

    returns

    whatever the action returns. Errors are thrown as IOException.

    Annotations
    @SuppressWarnings()

Deprecated Value Members

  1. def createTemporaryDirectory(prefix: String, maxTries: Int = 3): File

    Create a temporary directory.

    Create a temporary directory. Note: This function is deprecated, in favor of makeTemporaryDirectory, which does not throw exceptions.

    prefix

    Prefix for directory name

    maxTries

    Maximum number of times to try creating the directory before giving up.

    returns

    the directory. Throws an IOException if it can't create the directory.

    Annotations
    @deprecated @SuppressWarnings()
    Deprecated

    (Since version 4.5.0) Use makeTemporaryDirectory

Inherited from AnyRef

Inherited from Any

Ungrouped