|
85 | 85 | (Files/isDirectory (as-path f)
|
86 | 86 | (->link-opts nofollow-links))))
|
87 | 87 |
|
| 88 | +(def ^:private simple-link-opts |
| 89 | + (into-array LinkOption [])) |
| 90 | + |
| 91 | +(defn- directory-simple? |
| 92 | + [^Path f] (Files/isDirectory f simple-link-opts)) |
| 93 | + |
88 | 94 | (defn hidden?
|
89 | 95 | "Returns true if f is hidden."
|
90 | 96 | [f] (Files/isHidden (as-path f)))
|
|
308 | 314 | ([src dest {:keys [:replace-existing
|
309 | 315 | :copy-attributes
|
310 | 316 | :nofollow-links]}]
|
311 |
| - (let [copy-options (->copy-opts replace-existing copy-attributes false nofollow-links)] |
312 |
| - (if (directory? dest) |
| 317 | + (let [copy-options (->copy-opts replace-existing copy-attributes false nofollow-links) |
| 318 | + dest (as-path dest)] |
| 319 | + (if (directory-simple? dest) |
313 | 320 | (Files/copy (as-path src) (path dest (file-name src))
|
314 | 321 | copy-options)
|
315 |
| - (Files/copy (as-path src) (as-path dest) |
| 322 | + (Files/copy (as-path src) dest |
316 | 323 | copy-options)))))
|
317 | 324 |
|
318 | 325 | (defn posix->str
|
|
472 | 479 | (Files/createFile (as-path path) attrs))))
|
473 | 480 |
|
474 | 481 | (defn move
|
475 |
| - "Move or rename a file to a target file via Files/move." |
| 482 | + "Move or rename a file to a target dir or file via Files/move." |
476 | 483 | ([source target] (move source target nil))
|
477 | 484 | ([source target {:keys [:replace-existing
|
478 | 485 | :atomic-move
|
479 | 486 | :nofollow-links]}]
|
480 |
| - (Files/move (as-path source) |
481 |
| - (as-path target) |
482 |
| - (->copy-opts replace-existing false atomic-move nofollow-links)))) |
| 487 | + (let [target (as-path target)] |
| 488 | + (if (directory-simple? target) |
| 489 | + (Files/move (as-path source) |
| 490 | + (path target (file-name source)) |
| 491 | + (->copy-opts replace-existing false atomic-move nofollow-links)) |
| 492 | + (Files/move (as-path source) |
| 493 | + target |
| 494 | + (->copy-opts replace-existing false atomic-move nofollow-links)))))) |
483 | 495 |
|
484 | 496 | (defn parent
|
485 | 497 | "Returns parent of f, is it exists."
|
|
0 commit comments