mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Some minor fixes.
This commit is contained in:
parent
b2f50b3ac7
commit
f0ec5ac0d4
@ -43,7 +43,12 @@ function process.load(path, env, init, name)
|
||||
reason = "no exec command"
|
||||
else
|
||||
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
|
||||
else
|
||||
|
@ -1,6 +1,7 @@
|
||||
package li.cil.oc.server.fs
|
||||
|
||||
import java.io
|
||||
import java.io.FileNotFoundException
|
||||
|
||||
import li.cil.oc.api.fs.Mode
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
@ -45,17 +46,22 @@ trait Buffered extends OutputStreamFileSystem {
|
||||
else if (!exists(childPath) || !isDirectory(childPath)) {
|
||||
openOutputHandle(0, childPath, Mode.Write) match {
|
||||
case Some(stream) =>
|
||||
val in = new io.FileInputStream(childFile)
|
||||
val buffer = new Array[Byte](8 * 1024)
|
||||
var read = 0
|
||||
do {
|
||||
read = in.read(buffer)
|
||||
if (read > 0) {
|
||||
if (read == buffer.length) stream.write(buffer)
|
||||
else stream.write(buffer.view(0, read).toArray)
|
||||
}
|
||||
} while (read >= 0)
|
||||
in.close()
|
||||
try {
|
||||
val in = new io.FileInputStream(childFile)
|
||||
val buffer = new Array[Byte](8 * 1024)
|
||||
var read = 0
|
||||
do {
|
||||
read = in.read(buffer)
|
||||
if (read > 0) {
|
||||
if (read == buffer.length) stream.write(buffer)
|
||||
else stream.write(buffer.view(0, read).toArray)
|
||||
}
|
||||
} while (read >= 0)
|
||||
in.close()
|
||||
}
|
||||
catch {
|
||||
case _: FileNotFoundException => // File got deleted in the meantime.
|
||||
}
|
||||
stream.close()
|
||||
setLastModified(childPath, childFile.lastModified())
|
||||
case _ => // File is open for writing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user