7 public static class RECORD0
11 RandomAccessFile desc
;
13 public static void $COPY$
(RECORD0 dst
, RECORD0 src
)
16 dst
.regpath
= src
.regpath
;
20 void SetActive(RECORD1 rider
)
24 desc
.seek(rider
.position
);
29 public static class RECORD1
33 public boolean[] eof
= new boolean[1];
34 public int[] res
= new int[1];
36 public static void $COPY$
(RECORD1 dst
, RECORD1 src
)
39 dst
.position
= src
.position
;
40 dst
.eof
[0] = src
.eof
[0];
41 dst
.res
[0] = src
.res
[0];
45 public static RECORD0
Old(byte name
[])
48 RandomAccessFile filedesc
;
51 filepath
= new File(SYSTEM
.STRING(name
));
53 if(!filepath
.exists() || !filepath
.isFile())
60 filedesc
= new RandomAccessFile(filepath
, "rw");
66 filedesc
= new RandomAccessFile(filepath
, "r");
76 file
.regpath
= filepath
;
81 private static String
RandomString(int len
)
83 Random x
= new Random();
84 String s
= new String();
85 for(int i
= 0; i
< len
; i
++)
87 s
+= (char) (x
.nextInt(25) + 65);
92 public static RECORD0
New(byte name
[])
94 RandomAccessFile filedesc
;
102 String s
= (name
[0] == 0) ?
(".TMP") : SYSTEM
.STRING(name
);
103 filepath
= File
.createTempFile(s
, "tmp");
104 fileregpath
= new File(s
);
105 filedesc
= new RandomAccessFile(filepath
, "rw");
112 file
= new RECORD0();
113 file
.path
= filepath
;
114 file
.regpath
= fileregpath
.getAbsoluteFile();
115 file
.desc
= filedesc
;
119 public static void Register(RECORD0 f
)
123 java
.nio
.file
.Files
.move(
124 java
.nio
.file
.Paths
.get(f
.path
.getPath()),
125 java
.nio
.file
.Paths
.get(f
.regpath
.getPath()),
126 java
.nio
.file
.StandardCopyOption
.REPLACE_EXISTING
131 public static void Close(RECORD0 f
)
135 public static void Purge(RECORD0 f
)
142 public static void Delete(byte name
[], short res
[], int res$
)
144 File filepath
= new File(SYSTEM
.STRING(name
));
145 res
[res$
] = (short) (filepath
.delete() ?
(0) : (1));
148 public static void Rename(byte old
[], byte _new
[], short res
[], int res$
)
150 File oldpath
= new File(SYSTEM
.STRING(old
));
151 File newpath
= new File(SYSTEM
.STRING(_new
));
152 res
[res$
] = (short) (oldpath
.renameTo(newpath
) ?
(0) : (1));
155 public static int Length(RECORD0 f
)
159 return (int) f
.desc
.length();
162 public static void GetDate(RECORD0 f
, int t
[], int t$
, int d
[], int d$
)
164 long time
= f
.path
.lastModified();
165 Calendar cal
= Calendar
.getInstance();
166 cal
.setTimeInMillis(time
);
167 t
[t$
] = cal
.get(Calendar
.HOUR_OF_DAY
) * 4096 + cal
.get(Calendar
.MINUTE
) * 64 + cal
.get(Calendar
.SECOND
);
168 d
[d$
] = cal
.get(Calendar
.YEAR
) * 512 + cal
.get(Calendar
.MONTH
) * 32 + cal
.get(Calendar
.DAY_OF_WEEK
);
171 public static void Set(RECORD1 r
[], int r$
, RECORD0 f
, int pos
)
173 RECORD1 rider
= r
[r$
];
175 rider
.position
= pos
;
177 rider
.eof
[0] = false;
180 public static int Pos(RECORD1 r
[], int r$
)
182 return (int) r
[r$
].position
;
185 public static RECORD0
Base(RECORD1 r
[], int r$
)
190 public static void Read(RECORD1 r
[], int r$
, byte x
[], int x$
)
192 RECORD1 rider
= r
[r$
];
193 RandomAccessFile desc
= rider
.base
.desc
;
197 rider
.base
.SetActive(rider
);
198 x
[x$
] = (byte) desc
.read();
208 public static void ReadInt(RECORD1 R
[], int R$
, short x
[], int x$
)
210 byte[][] buf
= new byte[1][2];
211 ReadBytes(R
, R$
, buf
, 0, 2);
212 x
[x$
] = (short) ((buf
[0][1] & 0xff) << 8);
213 x
[x$
] |= (short) (buf
[0][0] & 0xff);
216 public static void ReadLInt(RECORD1 R
[], int R$
, int x
[], int x$
)
218 byte[][] buf
= new byte[1][4];
219 ReadBytes(R
, R$
, buf
, 0, 4);
220 x
[x$
] = (int) ((buf
[0][3] & 0xff) << 24);
221 x
[x$
] |= (int) ((buf
[0][2] & 0xff) << 16);
222 x
[x$
] |= (int) ((buf
[0][1] & 0xff) << 8);
223 x
[x$
] |= (int) ((buf
[0][0] & 0xff));
226 public static void ReadHInt(RECORD1 R
[], int R$
, long x
[], int x$
)
228 byte[][] buf
= new byte[1][8];
229 ReadBytes(R
, R$
, buf
, 0, 8);
230 x
[x$
] = (buf
[0][7] & 0xff) << 56;
231 x
[x$
] |= (buf
[0][6] & 0xff) << 48;
232 x
[x$
] |= (buf
[0][5] & 0xff) << 40;
233 x
[x$
] |= (buf
[0][4] & 0xff) << 32;
234 x
[x$
] |= (buf
[0][3] & 0xff) << 24;
235 x
[x$
] |= (buf
[0][2] & 0xff) << 16;
236 x
[x$
] |= (buf
[0][1] & 0xff) << 8;
237 x
[x$
] |= (buf
[0][0] & 0xff);
240 public static void ReadReal(RECORD1 R
[], int R$
, float x
[], int x$
)
242 int[] i
= new int[1];
243 ReadLInt(R
, R$
, i
, 0);
244 x
[x$
] = Float
.intBitsToFloat(i
[0]);
247 public static void ReadLReal(RECORD1 R
[], int R$
, double x
[], int x$
)
249 long[] i
= new long[1];
250 ReadHInt(R
, R$
, i
, 0);
251 x
[x$
] = Double
.longBitsToDouble(i
[0]);
254 public static void ReadNum(RECORD1 R
[], int R$
, int x
[], int x$
)
259 public static void ReadString(RECORD1 R
[], int R$
, byte x
[][], int x$
)
261 RECORD1 rider
= R
[R$
];
262 RandomAccessFile desc
= rider
.base
.desc
;
267 rider
.base
.SetActive(rider
);
270 ch
= x
[x$
][i
] = (byte) desc
.read();
283 public static void ReadSet(RECORD1 R
[], int R$
, int x
[], int x$
)
285 ReadLInt(R
, R$
, x
, x$
);
288 public static void ReadBool(RECORD1 R
[], int R$
, boolean x
[], int x$
)
290 byte[] i
= new byte[1];
295 public static void ReadBytes(RECORD1 r
[], int r$
, byte x
[][], int x$
, int n
)
297 RECORD1 rider
= r
[r$
];
298 RandomAccessFile desc
= rider
.base
.desc
;
302 rider
.base
.SetActive(rider
);
303 int readed
= desc
.read(x
[x$
], 0, n
);
304 rider
.res
[0] = (readed
>= 0) ?
(n
- readed
) : (0);
305 rider
.eof
[0] = (rider
.res
[0] != 0);
306 rider
.position
+= (readed
>= 0) ?
(readed
) : (0);
316 public static void Write(RECORD1 r
[], int r$
, byte x
)
318 RECORD1 rider
= r
[r$
];
319 RandomAccessFile desc
= rider
.base
.desc
;
323 rider
.base
.SetActive(rider
);
334 public static void WriteInt(RECORD1 R
[], int R$
, short x
)
336 byte[][] i
= new byte[1][2];
337 i
[0][1] = (byte) ((x
>>> 8) & 0xff);
338 i
[0][0] = (byte) ((x
) & 0xff);
339 WriteBytes(R
, R$
, i
, 0, 2);
342 public static void WriteLInt(RECORD1 R
[], int R$
, int x
)
344 byte[][] i
= new byte[1][4];
345 i
[0][3] = (byte) ((x
>>> 24) & 0xff);
346 i
[0][2] = (byte) ((x
>>> 16) & 0xff);
347 i
[0][1] = (byte) ((x
>>> 8) & 0xff);
348 i
[0][0] = (byte) ((x
) & 0xff);
349 WriteBytes(R
, R$
, i
, 0, 4);
352 public static void WriteReal(RECORD1 R
[], int R$
, float x
)
357 public static void WriteLReal(RECORD1 R
[], int R$
, double x
)
362 public static void WriteNum(RECORD1 R
[], int R$
, int x
)
367 public static void WriteString(RECORD1 R
[], int R$
, byte x
[])
369 byte[][] i
= new byte[1][];
371 WriteBytes(R
, R$
, i
, 0, SYSTEM
.LEN(x
) + 1);
374 public static void WriteSet(RECORD1 R
[], int R$
, int x
)
379 public static void WriteBool(RECORD1 R
[], int R$
, boolean x
)
384 public static void WriteBytes(RECORD1 r
[], int r$
, byte[][] x
, int x$
, int n
)
386 RECORD1 rider
= r
[r$
];
387 RandomAccessFile desc
= rider
.base
.desc
;
391 rider
.base
.SetActive(rider
);
392 desc
.write(x
[x$
], 0, n
);
402 public static void BEGIN()