Skip to content

Instantly share code, notes, and snippets.

@verma
Created April 4, 2014 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verma/9980396 to your computer and use it in GitHub Desktop.
Save verma/9980396 to your computer and use it in GitHub Desktop.
(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