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 ------------------------ ; ----------------------- Domain functions ------------------------
(def no-link-option (into-array [LinkOption/NOFOLLOW_LINKS])) (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 (s/defn path
[full-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 (try
(when (Files/exists path-from-fs no-link-option) (when (Files/exists path-from-fs follow-link-option)
path-from-fs) path-from-fs)
(catch Exception e (catch Exception e
nil)))) nil))))

View file

@ -17,4 +17,7 @@
(deftest test-path (deftest test-path
(is (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")))))