@@ -58,7 +58,7 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
5858 try {
5959 import scala .collection .JavaConverters ._
6060 val it = Files .newDirectoryStream(jpath).iterator()
61- it.asScala.map(new PlainNioFile (_ ))
61+ it.asScala.map(p => new PlainFile ( Path (p) ))
6262 } catch {
6363 case _ : NotDirectoryException => Iterator .empty
6464 }
@@ -90,76 +90,3 @@ class PlainFile(val givenPath: Path) extends AbstractFile {
9090 def lookupNameUnchecked (name : String , directory : Boolean ): AbstractFile =
9191 new PlainFile (givenPath / name)
9292}
93-
94- private [dotty] class PlainNioFile (nioPath : java.nio.file.Path ) extends AbstractFile {
95-
96- assert(nioPath ne null )
97-
98- def jpath = nioPath
99-
100- override def underlyingSource = Some (this )
101-
102- private val fpath = nioPath.toAbsolutePath.toString
103-
104- /** Returns the name of this abstract file. */
105- def name = nioPath.getFileName.toString
106-
107- /** Returns the path of this abstract file. */
108- def path = nioPath.toString
109-
110- /** The absolute file. */
111- def absolute = new PlainNioFile (nioPath.toAbsolutePath)
112-
113- override def container : AbstractFile = new PlainNioFile (nioPath.getParent)
114- override def input = Files .newInputStream(nioPath)
115- override def output = Files .newOutputStream(nioPath)
116- override def sizeOption = Some (Files .size(nioPath).toInt)
117- override def hashCode (): Int = fpath.hashCode()
118- override def equals (that : Any ): Boolean = that match {
119- case x : PlainNioFile => fpath == x.fpath
120- case _ => false
121- }
122-
123- /** Is this abstract file a directory? */
124- def isDirectory : Boolean = Files .isDirectory(nioPath)
125-
126- /** Returns the time that this abstract file was last modified. */
127- def lastModified : Long = Files .getLastModifiedTime(nioPath).toMillis
128-
129- /** Returns all abstract subfiles of this abstract directory. */
130- def iterator : Iterator [AbstractFile ] = {
131- try {
132- import scala .collection .JavaConverters ._
133- val it = Files .newDirectoryStream(nioPath).iterator()
134- it.asScala.map(new PlainNioFile (_))
135- } catch {
136- case _ : NotDirectoryException => Iterator .empty
137- }
138- }
139-
140- /**
141- * Returns the abstract file in this abstract directory with the
142- * specified name. If there is no such file, returns null. The
143- * argument "directory" tells whether to look for a directory or
144- * or a regular file.
145- */
146- def lookupName (name : String , directory : Boolean ): AbstractFile = {
147- val child = nioPath.resolve(name)
148- if ((Files .isDirectory(child) && directory) || (Files .isRegularFile(child) && ! directory)) new PlainNioFile (child)
149- else null
150- }
151-
152- /** Does this abstract file denote an existing file? */
153- def create (): Unit = if (! exists) Files .createFile(nioPath)
154-
155- /** Delete the underlying file or directory (recursively). */
156- def delete (): Unit =
157- if (Files .isRegularFile(nioPath)) Files .deleteIfExists(nioPath)
158- else if (Files .isDirectory(nioPath)) new Directory (nioPath).deleteRecursively()
159-
160- /** Returns a plain file with the given name. It does not
161- * check that it exists.
162- */
163- def lookupNameUnchecked (name : String , directory : Boolean ): AbstractFile =
164- new PlainNioFile (nioPath.resolve(name))
165- }
0 commit comments