@@ -13,8 +13,9 @@ import java.nio.file.{InvalidPathException, Paths}
13
13
14
14
/** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
15
15
class PlainDirectory (givenPath : Directory ) extends PlainFile (givenPath) {
16
- override val isDirectory : Boolean = true
16
+ override def isDirectory : Boolean = true
17
17
override def iterator (): Iterator [PlainFile ] = givenPath.list.filter(_.exists).map(new PlainFile (_))
18
+ override def delete (): Unit = givenPath.deleteRecursively()
18
19
}
19
20
20
21
/** This class implements an abstract file backed by a File.
@@ -77,7 +78,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
77
78
}
78
79
79
80
/** Is this abstract file a directory? */
80
- val isDirectory : Boolean = givenPath.isDirectory // cached for performance on Windows
81
+ def isDirectory : Boolean = givenPath.isDirectory
81
82
82
83
/** Returns the time that this abstract file was last modified. */
83
84
def lastModified : Long = givenPath.lastModified.toMillis
@@ -112,6 +113,14 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
112
113
null
113
114
}
114
115
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
+
115
124
/** Returns a plain file with the given name. It does not
116
125
* check that it exists.
117
126
*/
0 commit comments