Some minor fixes.

This commit is contained in:
Florian Nücke 2014-10-13 13:19:52 +02:00
parent b2f50b3ac7
commit f0ec5ac0d4
2 changed files with 23 additions and 12 deletions

View File

@ -43,7 +43,12 @@ function process.load(path, env, init, name)
reason = "no exec command" reason = "no exec command"
else else
code = function() code = function()
return require("shell").execute(command, env, path) local result = table.pack(require("shell").execute(command, env, path))
if not result[1] then
error(result[2], 0)
else
return table.unpack(result, 1, result.n)
end
end end
end end
else else

View File

@ -1,6 +1,7 @@
package li.cil.oc.server.fs package li.cil.oc.server.fs
import java.io import java.io
import java.io.FileNotFoundException
import li.cil.oc.api.fs.Mode import li.cil.oc.api.fs.Mode
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
@ -45,6 +46,7 @@ trait Buffered extends OutputStreamFileSystem {
else if (!exists(childPath) || !isDirectory(childPath)) { else if (!exists(childPath) || !isDirectory(childPath)) {
openOutputHandle(0, childPath, Mode.Write) match { openOutputHandle(0, childPath, Mode.Write) match {
case Some(stream) => case Some(stream) =>
try {
val in = new io.FileInputStream(childFile) val in = new io.FileInputStream(childFile)
val buffer = new Array[Byte](8 * 1024) val buffer = new Array[Byte](8 * 1024)
var read = 0 var read = 0
@ -56,6 +58,10 @@ trait Buffered extends OutputStreamFileSystem {
} }
} while (read >= 0) } while (read >= 0)
in.close() in.close()
}
catch {
case _: FileNotFoundException => // File got deleted in the meantime.
}
stream.close() stream.close()
setLastModified(childPath, childFile.lastModified()) setLastModified(childPath, childFile.lastModified())
case _ => // File is open for writing. case _ => // File is open for writing.