|
119 | 119 | (lambda (raw-from-path raw-to-path) |
120 | 120 | (let* [(from-path (canonicalise raw-from-path)) |
121 | 121 | (to-path (canonicalise raw-to-path))] |
122 | | - (if (not ((.> vfs :exists) from-path)) |
123 | | - (error! "No such file") |
124 | | - (if ((.> vfs :exists) to-path) |
125 | | - (error! "File exists") |
126 | | - (letrec [(copy-path (lambda (from to) |
127 | | - (log! (.. "copying " from " to " to)) |
128 | | - (if ((.> vfs :isDir) from) |
129 | | - (progn |
130 | | - ((.> vfs :makeDir) to) |
131 | | - (do [(path (struct->list ((.> vfs :list) from)))] |
132 | | - (copy-path (.. from "/" path) (.. to "/" path)))) |
133 | | - (let* [(read-handle ((.> vfs :open) from "r")) |
134 | | - (write-handle ((.> vfs :open) to "w"))] |
135 | | - ((.> write-handle :write) ((.> read-handle :readAll))) |
136 | | - ((.> read-handle :close)) |
137 | | - ((.> write-handle :close))))))] |
138 | | - (copy-path from-path to-path))))))) |
| 122 | + (if ((.> vfs :isReadOnly) to-path) |
| 123 | + (error! "Permission denied") |
| 124 | + (if (not ((.> vfs :exists) from-path)) |
| 125 | + (error! "No such file") |
| 126 | + (if ((.> vfs :exists) to-path) |
| 127 | + (error! "File exists") |
| 128 | + (letrec [(copy-path (lambda (from to) |
| 129 | + (log! (.. "copying " from " to " to)) |
| 130 | + (if ((.> vfs :isDir) from) |
| 131 | + (progn |
| 132 | + ((.> vfs :makeDir) to) |
| 133 | + (do [(path (struct->list ((.> vfs :list) from)))] |
| 134 | + (copy-path (.. from "/" path) (.. to "/" path)))) |
| 135 | + (let* [(read-handle ((.> vfs :open) from "r")) |
| 136 | + (write-handle ((.> vfs :open) to "w"))] |
| 137 | + ((.> write-handle :write) ((.> read-handle :readAll))) |
| 138 | + ((.> read-handle :close)) |
| 139 | + ((.> write-handle :close))))))] |
| 140 | + (copy-path from-path to-path)))))))) |
139 | 141 |
|
140 | 142 | (.<! vfs :move (lambda (from-path to-path) |
141 | 143 | ((.> vfs :copy) from-path to-path) |
|
0 commit comments