mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
Merge branch 'OC1.3-MC1.6.4' of github.com:MightyPirates/OpenComputers into OC1.3-MC1.7.10
This commit is contained in:
commit
b8519b432a
@ -118,9 +118,14 @@ object SaveHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete empty folders that match a drive UUID to keep the state folder clean.
|
||||
// Delete empty folders to keep the state folder clean.
|
||||
val emptyDirs = savePath.listFiles(new FileFilter {
|
||||
override def accept(file: File) = file.getName.matches(uuidRegex) && file.isDirectory && {
|
||||
override def accept(file: File) = file.isDirectory &&
|
||||
// Make sure we only consider file system folders (UUID).
|
||||
file.getName.matches(uuidRegex) &&
|
||||
// We set the modified time in the save() method of unbuffered file
|
||||
// systems, to avoid deleting in-use folders here.
|
||||
System.currentTimeMillis() - file.lastModified() > 60 * 1000 && {
|
||||
val list = file.list()
|
||||
list == null || list.length == 0
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.io
|
||||
import java.io.RandomAccessFile
|
||||
|
||||
import li.cil.oc.api.fs.Mode
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
trait FileOutputStreamFileSystem extends FileInputStreamFileSystem with OutputStreamFileSystem {
|
||||
override def spaceTotal = -1
|
||||
@ -12,7 +13,10 @@ trait FileOutputStreamFileSystem extends FileInputStreamFileSystem with OutputSt
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def delete(path: String) = new io.File(root, path).delete()
|
||||
override def delete(path: String) = {
|
||||
val file = new io.File(root, path)
|
||||
file == root || file.delete()
|
||||
}
|
||||
|
||||
override def makeDirectory(path: String) = new io.File(root, path).mkdir()
|
||||
|
||||
@ -28,6 +32,16 @@ trait FileOutputStreamFileSystem extends FileInputStreamFileSystem with OutputSt
|
||||
case _ => throw new IllegalArgumentException()
|
||||
}), this, id, path, mode))
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def save(nbt: NBTTagCompound) {
|
||||
super.save(nbt)
|
||||
root.mkdirs()
|
||||
root.setLastModified(System.currentTimeMillis())
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
protected class FileHandle(val file: RandomAccessFile, owner: OutputStreamFileSystem, handle: Int, path: String, mode: Mode) extends OutputHandle(owner, handle, path) {
|
||||
if (mode == Mode.Write) {
|
||||
file.setLength(0)
|
||||
|
@ -45,7 +45,7 @@ trait VirtualFileSystem extends OutputStreamFileSystem {
|
||||
|
||||
override def delete(path: String) = {
|
||||
val parts = segments(path)
|
||||
if (parts.isEmpty) false
|
||||
if (parts.isEmpty) true
|
||||
else {
|
||||
root.get(parts.dropRight(1)) match {
|
||||
case Some(parent: VirtualDirectory) => parent.delete(parts.last)
|
||||
|
Loading…
x
Reference in New Issue
Block a user