Created
April 4, 2014 18:25
-
-
Save verma/9980396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn join-path | |
"Join path elements together, if any of the path components start with a / | |
the function assumes that the path is being reset to root and will ignore all parts | |
before that" | |
[p & parts] | |
(let [p (if (empty? p) "." p)] | |
(.getPath (reduce #(if (.startsWith %2 "/") | |
(io/file %2) | |
(io/file %1 %2)) (io/file p) parts)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment