Carp/core/Filepath.carp

13 lines
336 B
Plaintext
Raw Normal View History

2018-04-23 17:14:40 +03:00
(defmodule Filepath
(use Array)
(doc dir-from-path "Removes the file-name part of a path to a file.")
(defn dir-from-path [path]
(let [segments (split-by path &[\/])
n (dec (length &segments))
2018-04-23 17:14:40 +03:00
without-last (prefix-array &segments n)]
2018-09-25 13:17:56 +03:00
(concat &(copy-map (fn [s] (str* s "/")) &without-last))))
2018-04-23 17:14:40 +03:00
)