From: DeaDDooMER Date: Tue, 22 Aug 2017 21:34:13 +0000 (+0300) Subject: Исправлена процедура Files.Register и реализована процедура Files.Write. Исправлен... X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=8620d81a0d78c987b250a7a471d76d96af461846;p=dsw-obn.git Исправлена процедура Files.Register и реализована процедура Files.Write. Исправлен оператор MOD. --- 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);