diff --git a/rtl/java/Files.java b/rtl/java/Files.java
index 5fe0074ca6293714b95895c070a78113ee14fcbe..c201940c21cbb37cc41a3f0b85ee546288cea4b9 100644 (file)
--- a/rtl/java/Files.java
+++ b/rtl/java/Files.java
try
{
- filepath = File.createTempFile(RandomString(8), "tmp");
- fileregpath = new File(SYSTEM.STRING(name));
+ String s = (name[0] == 0) ? (".TMP") : SYSTEM.STRING(name);
+ filepath = File.createTempFile(s, "tmp");
+ fileregpath = new File(s);
filedesc = new RandomAccessFile(filepath, "rw");
}
catch(IOException e)
file = new RECORD0();
file.path = filepath;
- file.regpath = fileregpath;
+ file.regpath = fileregpath.getAbsoluteFile();
file.desc = filedesc;
return file;
}
public static void Register(RECORD0 f)
+ throws
+ IOException
{
- f.path.renameTo(f.regpath);
+ java.nio.file.Files.move(
+ java.nio.file.Paths.get(f.path.getPath()),
+ java.nio.file.Paths.get(f.regpath.getPath()),
+ java.nio.file.StandardCopyOption.REPLACE_EXISTING
+ );
f.path = f.regpath;
}
public static void Write(RECORD1 r[], int r$, byte x)
{
- SYSTEM.TRAP(-3);
+ RECORD1 rider = r[r$];
+ RandomAccessFile desc = rider.base.desc;
+
+ try
+ {
+ rider.base.SetActive(rider);
+ desc.write(x);
+ rider.position += 1;
+ }
+ catch(IOException e)
+ {
+ rider.res[0] = 1;
+ rider.eof[0] = true;
+ }
}
public static void WriteInt(RECORD1 R[], int R$, short x)
{
- SYSTEM.TRAP(-3);
+ byte[][] i = new byte[1][2];
+ i[0][0] = (byte) ((x >>> 8) & 0xff);
+ i[0][1] = (byte) ((x) & 0xff);
+ WriteBytes(R, R$, i, 0, 2);
}
public static void WriteLInt(RECORD1 R[], int R$, int x)
{
- SYSTEM.TRAP(-3);
+ byte[][] i = new byte[1][4];
+ i[0][0] = (byte) ((x >>> 24) & 0xff);
+ i[0][1] = (byte) ((x >>> 16) & 0xff);
+ i[0][2] = (byte) ((x >>> 8) & 0xff);
+ i[0][3] = (byte) ((x) & 0xff);
+ WriteBytes(R, R$, i, 0, 4);
}
public static void WriteReal(RECORD1 R[], int R$, float x)
public static void WriteString(RECORD1 R[], int R$, byte x[])
{
- SYSTEM.TRAP(-3);
+ byte[][] i = new byte[1][];
+ i[0] = x;
+ WriteBytes(R, R$, i, 0, SYSTEM.LEN(x));
}
public static void WriteSet(RECORD1 R[], int R$, int x)
public static void WriteBytes(RECORD1 r[], int r$, byte[][] x, int x$, int n)
{
- SYSTEM.TRAP(-3);
+ RECORD1 rider = r[r$];
+ RandomAccessFile desc = rider.base.desc;
+
+ try
+ {
+ rider.base.SetActive(rider);
+ desc.write(x[x$], 0, n);
+ rider.position += n;
+ }
+ catch(IOException e)
+ {
+ rider.res[0] = n;
+ rider.eof[0] = true;
+ }
}
public static void BEGIN()