Made the thing Java 1.6 compatible again (at least it works on openjdk6). Should close #565 for good.

This commit is contained in:
Florian Nücke 2014-09-16 14:48:15 +02:00
parent 8511c836fa
commit 5e4758079f
3 changed files with 18 additions and 16 deletions

Binary file not shown.

Binary file not shown.

View File

@ -182,7 +182,7 @@ object SaveHandler {
// Touch all externally saved data when loading, to avoid it getting
// deleted in the next save (because the now - save time will usually
// be larger than the time out after loading a world again).
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) visitJava17()
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_7)) SaveHandlerJava17Functionality.visitJava17(statePath)
else visitJava16()
}
@ -196,21 +196,6 @@ object SaveHandler {
recurse(statePath)
}
private def visitJava17() {
Files.walkFileTree(statePath.toPath, new FileVisitor[Path] {
override def visitFile(file: Path, attrs: BasicFileAttributes) = {
file.toFile.setLastModified(System.currentTimeMillis())
FileVisitResult.CONTINUE
}
override def visitFileFailed(file: Path, exc: IOException) = FileVisitResult.CONTINUE
override def preVisitDirectory(dir: Path, attrs: BasicFileAttributes) = FileVisitResult.CONTINUE
override def postVisitDirectory(dir: Path, exc: IOException) = FileVisitResult.CONTINUE
})
}
@ForgeSubscribe
def onWorldSave(e: WorldEvent.Save) {
saveData.synchronized {
@ -237,3 +222,20 @@ object SaveHandler {
}
}
}
object SaveHandlerJava17Functionality {
def visitJava17(statePath: File) {
Files.walkFileTree(statePath.toPath, new FileVisitor[Path] {
override def visitFile(file: Path, attrs: BasicFileAttributes) = {
file.toFile.setLastModified(System.currentTimeMillis())
FileVisitResult.CONTINUE
}
override def visitFileFailed(file: Path, exc: IOException) = FileVisitResult.CONTINUE
override def preVisitDirectory(dir: Path, attrs: BasicFileAttributes) = FileVisitResult.CONTINUE
override def postVisitDirectory(dir: Path, exc: IOException) = FileVisitResult.CONTINUE
})
}
}