Skip to content

Commit

Permalink
Revert "A few changes to the new delete() code"
Browse files Browse the repository at this point in the history
This reverts commit 293f8ae.
  • Loading branch information
eed3si9n committed Jun 25, 2018
1 parent 301367d commit 55fd2ca
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions io/src/main/scala/sbt/io/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ import java.io.{
import java.io.{ ObjectInputStream, ObjectStreamClass, FileNotFoundException }
import java.net.{ URI, URISyntaxException, URL }
import java.nio.charset.Charset
import java.nio.file.{
FileSystems,
Files,
Path => NioPath,
SimpleFileVisitor,
FileVisitResult,
NoSuchFileException
}
import java.nio.file.attribute.{ PosixFilePermissions, BasicFileAttributes }
import java.nio.file.{FileSystems, Files, Paths, Path, SimpleFileVisitor, FileVisitResult}
import java.nio.file.attribute.{PosixFilePermissions, BasicFileAttributes}
import java.util.Properties
import java.util.jar.{ Attributes, JarEntry, JarOutputStream, Manifest }
import java.util.zip.{ CRC32, ZipEntry, ZipInputStream, ZipOutputStream }
Expand Down Expand Up @@ -462,36 +455,24 @@ object IO {

/** Deletes `file`, recursively if it is a directory. */
def delete(file: File): Unit = {
object deleter extends SimpleFileVisitor[NioPath] {
override def visitFile(file: NioPath, attr: BasicFileAttributes): FileVisitResult = {
translate("Error deleting file " + file.toFile + ": ") {
try {
Files.delete(file)
} catch {
case e: NoSuchFileException =>
}
object deleter extends SimpleFileVisitor[Path] {
override def visitFile(file: Path, attr: BasicFileAttributes): FileVisitResult = {
translate("Error deleting file " + file.toFile + ": "){
Files.delete(file)
}
FileVisitResult.CONTINUE
}

override def postVisitDirectory(dir: NioPath, e: IOException): FileVisitResult = {
override def postVisitDirectory(dir: Path, e: IOException): FileVisitResult = {
if (e eq null) {
translate("Error deleting file " + dir.toFile + ": ") {
try {
Files.delete(dir)
} catch {
case e: NoSuchFileException =>
}
Files.delete(dir)
}
FileVisitResult.CONTINUE
} else throw e // directory iteration failed
}
}
try {
Files.walkFileTree(file.toPath, deleter)
} catch {
case e: NoSuchFileException =>
}
Files.walkFileTree(file.toPath, deleter)
}

/** Returns the children of directory `dir` that match `filter` in a non-null array.*/
Expand Down

0 comments on commit 55fd2ca

Please sign in to comment.