mirror of
https://github.com/janet-lang/janet
synced 2025-01-08 06:30:28 +00:00
Improve error messages even more for copyfile
.
This commit is contained in:
parent
c02c2e3f02
commit
f9a6f52d9c
@ -4056,16 +4056,18 @@
|
|||||||
|
|
||||||
(defn- copyfile
|
(defn- copyfile
|
||||||
[from to]
|
[from to]
|
||||||
(def mode (os/stat from :permissions))
|
(if-with [ffrom (file/open from :rb)]
|
||||||
(if-not mode (errorf "file %s does not exist" from))
|
(if-with [fto (file/open to :wb)]
|
||||||
|
(do
|
||||||
|
(def perm (os/stat from :permissions))
|
||||||
(def b (buffer/new 0x10000))
|
(def b (buffer/new 0x10000))
|
||||||
(with [ffrom (file/open from :rb)]
|
|
||||||
(with [fto (file/open to :wb)]
|
|
||||||
(forever
|
(forever
|
||||||
(file/read ffrom 0x10000 b)
|
(file/read ffrom 0x10000 b)
|
||||||
(when (empty? b) (buffer/trim b) (os/chmod to mode) (break))
|
(when (empty? b) (buffer/trim b) (os/chmod to perm) (break))
|
||||||
(file/write fto b)
|
(file/write fto b)
|
||||||
(buffer/clear b)))))
|
(buffer/clear b)))
|
||||||
|
(errorf "destination file %s cannot be opened for writing" to))
|
||||||
|
(errorf "source file %s cannot be opened for reading" from)))
|
||||||
|
|
||||||
(defn- copyrf
|
(defn- copyrf
|
||||||
[from to]
|
[from to]
|
||||||
|
Loading…
Reference in New Issue
Block a user