DEADSOFTWARE

Исправлена процедура Files.Register и реализована процедура Files.Write. Исправлен...
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 22 Aug 2017 21:34:13 +0000 (00:34 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 22 Aug 2017 21:34:13 +0000 (00:34 +0300)
rtl/java/Files.java
src/oberon.c

index 5fe0074ca6293714b95895c070a78113ee14fcbe..5ccfa25acacc8822278fce3aa1f2039837e6fd59 100644 (file)
@@ -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)
index 4a740d8130db2be573d6c197eadc2ee767244d3c..f6bd09e68cc85998290d4ed9fd8c94f3b5c2d6d1 100644 (file)
@@ -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);