grizzled.file

util

object util extends AnyRef

Useful file-related utility functions.

linear super types: AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. util
  2. AnyRef
  3. Any
Visibility
  1. Public
  2. All
Impl.
  1. Concrete
  2. Abstract

Value Members

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

    attributes: final
    definition classes: AnyRef
  2. def != (arg0: Any) : Boolean

    o != arg0 is the same as !(o == (arg0)).

    o != arg0 is the same as !(o == (arg0)).

    arg0

    the object to compare against this object for dis-equality.

    returns

    false if the receiver object is equivalent to the argument; true otherwise.

    attributes: final
    definition classes: Any
  3. def ## () : Int

    attributes: final
    definition classes: AnyRef → Any
  4. def $asInstanceOf [T0] () : T0

    attributes: final
    definition classes: AnyRef
  5. def $isInstanceOf [T0] () : Boolean

    attributes: final
    definition classes: AnyRef
  6. def == (arg0: AnyRef) : Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: AnyRef
  7. def == (arg0: Any) : Boolean

    o == arg0 is the same as o.equals(arg0).

    o == arg0 is the same as o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: Any
  8. def asInstanceOf [T0] : T0

    This method is used to cast the receiver object to be of type T0.

    This method is used to cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    the receiver object.

    attributes: final
    definition classes: Any
  9. def basename (path: String, fileSep: String = ...) : 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

  10. def clone () : AnyRef

    This method creates and returns a copy of the receiver object.

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    attributes: protected
    definition classes: AnyRef
  11. def copy (file: String, targetDir: String) : Unit

    Copy a file to a directory.

    Copy a file to a directory. If the target directory does not exist, it is created.

    file

    Path name of the file to copy

    targetDir

    Path name to target directory

  12. def copy (file: String, targetDir: String, createTarget: Boolean) : Unit

    Copy a file to a directory.

    Copy a file to a directory.

    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.

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

    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.

  14. def copyFile (source: File, target: File) : 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.

    source

    path to the source file

    target

    path to the target file or directory

    returns

    the full path of the target file

  15. def copyFile (sourcePath: String, targetPath: String) : 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.

    sourcePath

    path to the source file

    targetPath

    path to the target file or directory

    returns

    the full path of the target file

  16. def copyTree (sourceDir: File, targetDir: File) : Unit

    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

  17. def copyTree (sourceDir: String, targetDir: String) : Unit

    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

  18. def createTemporaryDirectory (prefix: String, maxTries: Int =3) : 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

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

  19. def deleteTree (dir: File) : 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

  20. 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

  21. def dirname (path: String, fileSep: String = ...) : 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

  22. def dirnameBasename (path: String, fileSep: String = ...) : (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

  23. def dirnameBasenameExtension (pathname: String, fileSep: String = ...) : (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)

  24. 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.

    pattern

    the wildcard pattern

    returns

    list of matches, or an empty list for none

  25. def eq (arg0: AnyRef) : Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of AnyRef: * It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true. * It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and only if y.eq(x) returns true. * It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.

    Additionally, the eq method has three other properties. * It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false. * For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false. * null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    arg0

    the object to compare against this object for reference equality.

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    attributes: final
    definition classes: AnyRef
  26. def equals (arg0: Any) : Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

    The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]: * It is reflexive: for any instance x of type Any, x.equals(x) should return true. * It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true. * It is transitive: for any instances x, y, and z of type AnyRef if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

    If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is often necessary to override hashCode to ensure that objects that are "equal" (o1.equals(o2) returns true) hash to the same scala.Int (o1.hashCode.equals(o2.hashCode)).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    definition classes: AnyRef → Any
  27. val fileSeparator : String

  28. val fileSeparatorChar : Char

  29. def finalize () : Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.

    attributes: protected
    definition classes: AnyRef
  30. 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 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

  31. def getClass () : java.lang.Class[_]

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef
  32. 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().

    path

    The path to expand.

    returns

    a list of possibly expanded file names

  33. def hashCode () : Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    returns

    the hash code value for the object.

    definition classes: AnyRef → Any
  34. def isInstanceOf [T0] : Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

    This method is used to test whether the dynamic type of the receiver object is T0.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    attributes: final
    definition classes: Any
  35. def joinPath (pieces: File*) : File

    Join components of a path together, using the file separator of the currently running system

    Join components of a path together, using the file separator of the currently running system

    pieces

    path pieces

    returns

    a composite path

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

    Join components of a path together, using the file separator of the currently running system

    Join components of a path together, using the file separator of the currently running system

    pieces

    path pieces

    returns

    a composite path

  37. def joinPath (fileSep: String, pieces: List[String]) : String

    Join components of a path together.

    Join components of a path together.

    fileSep

    the file separator to use

    pieces

    path pieces

    returns

    a composite path

  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. def ne (arg0: AnyRef) : Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

    o.ne(arg0) is the same as !(o.eq(arg0)).

    arg0

    the object to compare against this object for reference dis-equality.

    returns

    false if the argument is not a reference to the receiver object; true otherwise.

    attributes: final
    definition classes: AnyRef
  40. def normalizePath (path: String) : String

    Normalize a path, eliminating double slashes, resolving embedded ".

    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'sos.

    Adapted from the Python version of normpath() in Python'sos.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. def notify () : Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  44. def notifyAll () : Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  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 = ...) : 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. def synchronized [T0] (arg0: T0) : T0

    attributes: final
    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

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

    a string representation of the object.

    definition classes: AnyRef → Any
  52. def touch (path: String, time: Long =-1) : Unit

    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 throw an exception.

    path

    The file to touch

    time

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

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

    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 any non-existent files in the list of files

    If any file in the list is a directory, this method will throw an exception.

    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.

  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 thenative_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. def wait () : Unit

    attributes: final
    definition classes: AnyRef
  56. def wait (arg0: Long, arg1: Int) : Unit

    attributes: final
    definition classes: AnyRef
  57. def wait (arg0: Long) : Unit

    attributes: final
    definition classes: AnyRef
  58. def walk (top: String, topdown: Boolean =true) : List[(String, List[String], List[String])]

    Directory tree generator, adapted from Python's os.

    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 indirpath (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 indirpath, 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 isfalse, 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!

    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

Inherited from AnyRef

Inherited from Any