1
0
mirror of https://github.com/janet-lang/janet synced 2025-07-04 19:12:55 +00:00

copyfile should copy permission bits

This commit is contained in:
Calvin Rose 2024-05-29 19:37:14 -05:00
parent 8fca6b7af4
commit f4fd481415

View File

@ -4019,12 +4019,13 @@
(defn- copyfile (defn- copyfile
[from to] [from to]
(def mode (os/stat from :permissions))
(def b (buffer/new 0x10000)) (def b (buffer/new 0x10000))
(with [ffrom (file/open from :rb)] (with [ffrom (file/open from :rb)]
(with [fto (file/open to :wb)] (with [fto (file/open to :wb)]
(forever (forever
(file/read ffrom 0x10000 b) (file/read ffrom 0x10000 b)
(when (empty? b) (buffer/trim b) (break)) (when (empty? b) (buffer/trim b) (os/chmod to mode) (break))
(file/write fto b) (file/write fto b)
(buffer/clear b))))) (buffer/clear b)))))