mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Update slurp and spit error handler.
This commit is contained in:
parent
5bf9e4fc89
commit
68e00cdb7a
@ -1712,6 +1712,7 @@ value, one key will be ignored."
|
|||||||
and then close the file."
|
and then close the file."
|
||||||
[path]
|
[path]
|
||||||
(def f (file/open path :r))
|
(def f (file/open path :r))
|
||||||
|
(if-not f (error (string "could not open file " path)))
|
||||||
(def contents (file/read f :all))
|
(def contents (file/read f :all))
|
||||||
(file/close f)
|
(file/close f)
|
||||||
contents)
|
contents)
|
||||||
@ -1722,6 +1723,7 @@ value, one key will be ignored."
|
|||||||
[path contents mode &]
|
[path contents mode &]
|
||||||
(default mode :w)
|
(default mode :w)
|
||||||
(def f (file/open path mode))
|
(def f (file/open path mode))
|
||||||
|
(if-not f (error (string "could not open file " path " with mode " mode)))
|
||||||
(file/write f contents)
|
(file/write f contents)
|
||||||
(file/close f)
|
(file/close f)
|
||||||
nil)
|
nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user