implicit class GrizzledFile extends AnyRef
A wrapper for java.io.File that provides additional methods.
By importing the implicit conversion functions, you can use the methods
in this class transparently from a java.io.File object.
import grizzled.file.GrizzledFile._ val file = new File("/tmp/foo/bar") println(file.split) // prints: List(/tmp, foo, bar)
- Alphabetic
- By Inheritance
- GrizzledFile
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new GrizzledFile(file: File)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
basename: File
Get the basename (file name only) part of a path.
Get the basename (file name only) part of a path.
- returns
the file name portion, as a
File
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
copyTo(target: File): Try[File]
Copy the file to a target directory or file.
Copy the file to a target directory or file.
- target
path to the target file or directory
- returns
A
Successcontaining the target file, orFailure(exception)
-
def
copyTo(target: String): Try[File]
Copy the file to a target directory or file.
Copy the file to a target directory or file.
- target
path to the target file or directory
- returns
A
Successcontaining the target file, orFailure(exception)
-
def
deleteRecursively(): Try[Int]
Recursively remove the directory specified by this object.
Recursively remove the directory specified by this object. This method is conceptually equivalent to
rm -ron a Unix system.- returns
Failure(exception)orSuccess(total), wheretotalis the number of files and directories actually deleted.
-
def
dirname: File
Get the directory name of the file.
Get the directory name of the file.
- returns
the directory portion, as a
File.
-
def
dirnameBasename: (File, File)
Split the file's path into directory (dirname) and file (basename) components.
Split the file's path into directory (dirname) and file (basename) components. Analogous to Python's
os.path.pathsplit()function.- returns
a (dirname, basename) tuple of
Fileobjects.
-
def
dirnameBasenameExtension: (File, String, String)
Split this file's pathname into the directory name, basename, and extension pieces.
Split this file's pathname into the directory name, basename, and extension pieces.
- returns
a 3-tuple of (dirname, basename, extension)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val file: File
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isEmpty: Boolean
Determine whether a directory is empty.
Determine whether a directory is empty. Only meaningful for a directory.
- returns
true if the directory is empty, false if not
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
listRecursively(topdown: Boolean = true): LazyList[File]
List a directory recursively, returning
Fileobjects for each file (and subdirectory) found.List a directory recursively, returning
Fileobjects for each file (and subdirectory) found. This method does lazy evaluation, instead of calculating everything up-front, aswalk()does.If
topdownistrue, a directory is generated before the entries for any of its subdirectories (directories are generated top down). Iftopdownisfalse, a directory directory is generated after the entries for all of its subdirectories (directories are generated bottom up).- topdown
trueto do a top-down traversal,falseotherwise.- returns
a lazy sequence of
Fileobjects for everything under the directory. This sequence will be aLazyList(typedef'd) in Scala 2.13 or better, and aStreamin Scala 2.12 and older.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
pathExists: Try[Boolean]
A version of
java.io.File.existsthat returns aTry, this method tests the existence of the file.A version of
java.io.File.existsthat returns aTry, this method tests the existence of the file.- returns
Success(true)if the file exists, andFailure(FileDoesNotExistException)if it does not.
-
def
relativePath(relativeTo: File): String
Get the path of this file, relative to some other file.
Get the path of this file, relative to some other file.
- relativeTo
the other file
- returns
the path of this file, relative to the other file.
-
def
split: List[String]
Split this file's path into its constituent components.
Split this file's 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") - returns
the component pieces.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
touch(time: Long = -1l): Try[Boolean]
Similar to the Unix touch command, this function:
Similar to the Unix touch command, this function:
- updates the access and modification time for the path represented by this object
- creates the path (as a file), if it does not exist
If the file corresponds to an existing directory, this method will return an error.
- time
Set the last-modified time to this time, or to the current time if this parameter is negative.
- returns
Success(true)on success,Failure(exception)on error.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )