Advertisement
Guest User

Untitled

a guest
May 1st, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. (defn- ^File path-cat
  2. "Concatenate a path onto a file, with the same semantics as 'file."
  3. [f p]
  4. {:pre [f, p], :post [(cast File %)]}
  5. (let [f2 (io/file p)]
  6. (if (.isAbsolute f2) (io/file p) (io/file f p))))
  7.  
  8. (defn ^File file
  9. "Concatenate one or more paths. Absolute paths overrule all previous paths.
  10. Concatenating a/b/c with /d/e/f results in /d/e/f."
  11. [path & more]
  12. {:pre [path], :post [(cast File %)]}
  13. (let [f (io/file path)]
  14. (if (empty? more) (io/file f) (reduce path-cat f more))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement