This commit is contained in:
bom 2020-01-31 15:36:30 +01:00
parent 805b2b8842
commit 2d71596a5e
2 changed files with 10 additions and 3 deletions

View file

@ -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))))

View file

@ -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")))))