mirror of
https://github.com/taoensso/telemere.git
synced 2025-12-16 17:41:12 +00:00
[fix] [#57] File handling: use nio API to create missing parent dirs
Skimming the docs, it seems that the nio API might be better able to create dirs for edge cases like symbolic links, etc.?
This commit is contained in:
parent
79173a68cc
commit
af45ffc396
1 changed files with 7 additions and 3 deletions
|
|
@ -209,7 +209,7 @@
|
|||
chain (truss/ex-chain :as-map error)]
|
||||
(assoc signal :error chain)
|
||||
(do signal)))
|
||||
|
||||
|
||||
;;;; Files
|
||||
|
||||
#?(:clj (defn ^:no-doc as-file ^java.io.File [file] (jio/as-file file)))
|
||||
|
|
@ -220,8 +220,12 @@
|
|||
^java.io.File [file]
|
||||
(let [file (as-file file)]
|
||||
(when-not (.exists file)
|
||||
(when-let [parent (.getParentFile (.getCanonicalFile file))] (.mkdirs parent))
|
||||
(.createNewFile file))
|
||||
(truss/catching
|
||||
(let [path (.toPath file)
|
||||
fa (into-array java.nio.file.attribute.FileAttribute [])]
|
||||
(when-let [parent (.getParent path)]
|
||||
(do (java.nio.file.Files/createDirectories parent fa)))
|
||||
(do (java.nio.file.Files/createFile path fa)))))
|
||||
|
||||
(if (.canWrite file)
|
||||
file
|
||||
|
|
|
|||
Loading…
Reference in a new issue