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,17 +46,22 @@ 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) =>
val in = new io.FileInputStream(childFile) try {
val buffer = new Array[Byte](8 * 1024) val in = new io.FileInputStream(childFile)
var read = 0 val buffer = new Array[Byte](8 * 1024)
do { var read = 0
read = in.read(buffer) do {
if (read > 0) { read = in.read(buffer)
if (read == buffer.length) stream.write(buffer) if (read > 0) {
else stream.write(buffer.view(0, read).toArray) if (read == buffer.length) stream.write(buffer)
} else stream.write(buffer.view(0, read).toArray)
} while (read >= 0) }
in.close() } while (read >= 0)
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.