Skip to content

Commit

Permalink
CHANGE: Have EXISTS? return the type field or none instead of true/false
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 20, 2020
1 parent 4280e0a commit 0688a19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/mezz/base-files.reb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ exists?: func [
{Determines if a file or URL exists.}
target [file! url!]
][
either error? try [
target: query/mode target 'type
][ false ][ not none? target ]
all [
word? target: try [query/mode target 'type]
target
]
]

size?: func [
Expand Down
6 changes: 4 additions & 2 deletions src/tests/units/port-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ if system/platform = 'Windows [
]
--test-- "exists? %/"
;@@ https://github.com/Oldes/Rebol-issues/issues/2317
--assert exists? %/
--assert 'dir = exists? %/ ;@@ https://github.com/Oldes/Rebol-issues/issues/612
--assert object? info: query %/
--assert info/name = %/
--assert info/type = 'dir
Expand Down Expand Up @@ -141,6 +141,8 @@ if system/platform = 'Windows [
--assert ["a" ""] = read/lines %tmp.txt
;@@ https://github.com/Oldes/Rebol-issues/issues/2429
--assert "a^/b^/" = read/string write/lines %tmp.txt ["a" "b"]
;@@ https://github.com/Oldes/Rebol-issues/issues/612
--assert 'file = exists? %tmp.txt
delete %tmp.txt

--test-- "read/lines - issue/1794"
Expand Down Expand Up @@ -223,7 +225,7 @@ if system/platform = 'Windows [
--test-- "exists? url"
;@@ https://github.com/Oldes/Rebol3/issues/14
;@@ https://github.com/Oldes/Rebol-issues/issues/1613
--assert exists? http://httpbin.org/
--assert 'url = exists? http://httpbin.org/ ;@@ https://github.com/Oldes/Rebol-issues/issues/612
--assert not exists? http://httpbin.org/not-exists
--test-- "read/part"
;@@ https://github.com/Oldes/Rebol-issues/issues/2434
Expand Down

0 comments on commit 0688a19

Please sign in to comment.