@@ -13,8 +13,9 @@ import java.nio.file.{InvalidPathException, Paths}
1313
1414/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
1515class PlainDirectory (givenPath : Directory ) extends PlainFile (givenPath) {
16- override val isDirectory : Boolean = true
16+ override def isDirectory : Boolean = true
1717 override def iterator (): Iterator [PlainFile ] = givenPath.list.filter(_.exists).map(new PlainFile (_))
18+ override def delete (): Unit = givenPath.deleteRecursively()
1819}
1920
2021/** This class implements an abstract file backed by a File.
@@ -77,7 +78,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
7778 }
7879
7980 /** Is this abstract file a directory? */
80- val isDirectory : Boolean = givenPath.isDirectory // cached for performance on Windows
81+ def isDirectory : Boolean = givenPath.isDirectory
8182
8283 /** Returns the time that this abstract file was last modified. */
8384 def lastModified : Long = givenPath.lastModified.toMillis
@@ -112,6 +113,14 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
112113 null
113114 }
114115
116+ /** Does this abstract file denote an existing file? */
117+ def create (): Unit = if (! exists) givenPath.createFile()
118+
119+ /** Delete the underlying file or directory (recursively). */
120+ def delete (): Unit =
121+ if (givenPath.isFile) givenPath.delete()
122+ else if (givenPath.isDirectory) givenPath.toDirectory.deleteRecursively()
123+
115124 /** Returns a plain file with the given name. It does not
116125 * check that it exists.
117126 */
0 commit comments