bom 4 years ago
parent 805b2b8842
commit 2d71596a5e

@ -17,12 +17,16 @@
; ----------------------- Domain functions ------------------------
(def no-link-option (into-array [LinkOption/NOFOLLOW_LINKS]))
(def follow-link-option (into-array []))
(defn user-dir []
(java.lang.System/getProperty "user.dir"))
(s/defn path
[full-path]
(let [path-from-fs (Paths/get (URI. (str "file://" full-path)))] ;fragile
(let [path-from-fs (Paths/get (URI. (str "file://" (user-dir) "/" full-path)))]
(try
(when (Files/exists path-from-fs no-link-option)
(when (Files/exists path-from-fs follow-link-option)
path-from-fs)
(catch Exception e
nil))))

@ -17,4 +17,7 @@
(deftest test-path
(is
(sut/path (str fs-root "dummy/dummy_from_fs"))))
(sut/path (str fs-root "/dummy/dummy_from_fs")))
(is
(= nil
(sut/path (str fs-root "/not-existing")))))

Loading…
Cancel
Save