From 8620d81a0d78c987b250a7a471d76d96af461846 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Wed, 23 Aug 2017 00:34:13 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80?= =?utf8?q?=D0=B0=20Files.Register=20=D0=B8=20=D1=80=D0=B5=D0=B0=D0=BB?= =?utf8?q?=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE?= =?utf8?q?=D1=86=D0=B5=D0=B4=D1=83=D1=80=D0=B0=20Files.Write.=20=D0=98?= =?utf8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D0=BE=D0=BF?= =?utf8?q?=D0=B5=D1=80=D0=B0=D1=82=D0=BE=D1=80=20MOD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- rtl/java/Files.java | 27 +++++++++++++++++++++++---- src/oberon.c | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/rtl/java/Files.java b/rtl/java/Files.java index 5fe0074..5ccfa25 100644 --- a/rtl/java/Files.java +++ b/rtl/java/Files.java @@ -99,7 +99,7 @@ class Files try { - filepath = File.createTempFile(RandomString(8), "tmp"); + filepath = File.createTempFile(SYSTEM.STRING(name), "tmp"); fileregpath = new File(SYSTEM.STRING(name)); filedesc = new RandomAccessFile(filepath, "rw"); } @@ -110,14 +110,20 @@ class Files 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; } @@ -351,7 +357,20 @@ class Files 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) diff --git a/src/oberon.c b/src/oberon.c index 4a740d8..f6bd09e 100644 --- a/src/oberon.c +++ b/src/oberon.c @@ -1995,7 +1995,7 @@ oberon_make_bin_op(oberon_context_t * ctx, int token, oberon_expr_t * a, oberon_ expr = oberon_new_operator(OP_DIV, result, a, b); break; case MOD: - expr = oberon_new_operator(OP_DIV, result, a, b); + expr = oberon_new_operator(OP_MOD, result, a, b); break; default: printf("token %i line %i\n", token, ctx -> loc.line); -- 2.29.2