Skip to content

Commit

Permalink
FEAT: WRITE action if used on FILE is returning the same file name in…
Browse files Browse the repository at this point in the history
…stead 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: metaeducation/rebol-issues#2337

Note: `save` function is now also returning file!
  • Loading branch information
Oldes committed Dec 18, 2018
1 parent 01391f1 commit af0eb92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core/p-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ REBINT Mode_Syms[] = {
}

if (file->error) Trap1(RE_WRITE_ERROR, path);
*D_RET = *path;
break;

case A_OPEN:
Expand Down
2 changes: 1 addition & 1 deletion src/tests/units/compress-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/tests/units/port-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -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" [
Expand Down

0 comments on commit af0eb92

Please sign in to comment.