mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 11:09:54 +00:00
file/linex now only acceps a file, not a path name
This commit is contained in:
parent
64e3cdeb2b
commit
09345ec786
@ -1749,18 +1749,13 @@
|
||||
(printf (dyn *pretty-format* "%q") x)
|
||||
(flush))
|
||||
|
||||
|
||||
(defn file/lines
|
||||
"Return an iterator over the lines of a file"
|
||||
[file-or-path &opt mode]
|
||||
(default mode :r)
|
||||
(if (bytes? file-or-path)
|
||||
"Return an iterator over the lines of a file."
|
||||
[file]
|
||||
(coro
|
||||
(with [f (file/open file-or-path mode)]
|
||||
(while (def line (file/read f :line))
|
||||
(while (def line (file/read file :line))
|
||||
(yield line))))
|
||||
(coro
|
||||
(while (def line (file/read file-or-path :line))
|
||||
(yield line)))))
|
||||
|
||||
###
|
||||
###
|
||||
|
@ -110,8 +110,9 @@
|
||||
(defer (:close outstream)
|
||||
(:write outstream buf1))
|
||||
(var buf2 "")
|
||||
(each line (file/lines "unique.txt")
|
||||
(set buf2 (string buf2 line)))
|
||||
(with [f (file/open "unique.txt" :r)]
|
||||
(each line (file/lines f)
|
||||
(set buf2 (string buf2 line))))
|
||||
(assert (= buf1 buf2) "file/lines iterator")
|
||||
(os/rm "unique.txt"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user