From af0eb92688ef5a4f1186a581383dc1b4f5e5d6cc Mon Sep 17 00:00:00 2001 From: Oldes Date: Wed, 19 Dec 2018 00:26:45 +0100 Subject: [PATCH] FEAT: WRITE action if used on FILE is returning the same file name instead of (closed) port! It enables chaining actions... for example: ``` >> query write %xxx "a" == make object! [ name: %/X/GIT/Rebol/release-x64/xxx size: 1 date: 19-Dec-2018/0:17:51.338+1:00 type: 'file ] ``` Related to: https://github.com/rebol/rebol-issues/issues/2337 Note: `save` function is now also returning file! --- src/core/p-file.c | 1 + src/tests/units/compress-test.r3 | 2 +- src/tests/units/port-test.r3 | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/p-file.c b/src/core/p-file.c index e8c96cd20d..acae756b4c 100644 --- a/src/core/p-file.c +++ b/src/core/p-file.c @@ -482,6 +482,7 @@ REBINT Mode_Syms[] = { } if (file->error) Trap1(RE_WRITE_ERROR, path); + *D_RET = *path; break; case A_OPEN: diff --git a/src/tests/units/compress-test.r3 b/src/tests/units/compress-test.r3 index 8db1d3c309..625777bac8 100644 --- a/src/tests/units/compress-test.r3 +++ b/src/tests/units/compress-test.r3 @@ -74,7 +74,7 @@ data: "test test test" --test-- "GZIP codec" --assert binary? alice: load %units/files/alice29.txt.gz --assert #{37A087D23C8709E97AA45ECE662FAF3D07006A58} = checksum/method alice 'sha1 - --assert port? save %units/files/tmp.gz alice + --assert file? save %units/files/tmp.gz alice --assert binary? alice: load %units/files/tmp.gz --assert #{37A087D23C8709E97AA45ECE662FAF3D07006A58} = checksum/method alice 'sha1 delete %units/files/tmp.gz diff --git a/src/tests/units/port-test.r3 b/src/tests/units/port-test.r3 index 6c26533ff8..fc51ab2abb 100644 --- a/src/tests/units/port-test.r3 +++ b/src/tests/units/port-test.r3 @@ -51,6 +51,12 @@ Rebol [ --assert ["a" ""] = read/lines %tmp.txt delete %tmp.txt + --test-- "write file result - wish/2337" + ;@@ https://github.com/rebol/rebol-issues/issues/2337 + --assert file? write %foo "hello" + --assert "hello" = read/string write %foo "hello" + delete %foo + ===end-group=== if "true" <> get-env "CONTINUOUS_INTEGRATION" [