|
1 | 1 | package os
|
2 | 2 |
|
3 | 3 | import java.net.URI
|
4 |
| -import java.nio.file.Paths |
| 4 | +import java.nio.file.{LinkOption, Paths} |
5 | 5 | import java.nio.file.Files
|
6 | 6 |
|
7 | 7 | import collection.JavaConverters._
|
@@ -282,7 +282,7 @@ class RelPath private[os] (segments0: Array[String], val ups: Int)
|
282 | 282 | case _ => false
|
283 | 283 | }
|
284 | 284 |
|
285 |
| - def toNIO = Paths.get(toString) |
| 285 | + def toNIO = java.nio.file.Paths.get(toString) |
286 | 286 |
|
287 | 287 | def asSubPath = {
|
288 | 288 | require(ups == 0)
|
@@ -343,7 +343,7 @@ class SubPath private[os] (val segments0: Array[String])
|
343 | 343 | case _ => false
|
344 | 344 | }
|
345 | 345 |
|
346 |
| - def toNIO = Paths.get(toString) |
| 346 | + def toNIO = java.nio.file.Paths.get(toString) |
347 | 347 |
|
348 | 348 | def resolveFrom(base: os.Path) = base / this
|
349 | 349 | }
|
@@ -509,7 +509,16 @@ class TempPath private[os] (wrapped: java.nio.file.Path)
|
509 | 509 | */
|
510 | 510 | private def deleteRecursively(ioPath: java.nio.file.Path): Unit = {
|
511 | 511 | if (Files.isDirectory(ioPath)) {
|
512 |
| - Files.list(ioPath).forEach(deleteRecursively) |
| 512 | + // while we support Scala 2.11 we need (something like) this: |
| 513 | + Files.list(ioPath).forEach( |
| 514 | + new java.util.function.Consumer[java.nio.file.Path] { |
| 515 | + override def accept(path: java.nio.file.Path): Unit = |
| 516 | + deleteRecursively(path) |
| 517 | + } |
| 518 | + ) |
| 519 | + |
| 520 | + // this works for Scala 2.12+ |
| 521 | + // Files.list(ioPath).forEach(deleteRecursively) |
513 | 522 | }
|
514 | 523 | Files.deleteIfExists(ioPath)
|
515 | 524 | }
|
|
0 commit comments