1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 16:30:26 +00:00

Update create-dirs to work on windows style paths.

This commit is contained in:
Calvin Rose 2020-04-25 12:01:09 -04:00
parent fce1529bf2
commit 8ce092da68

View File

@ -177,14 +177,6 @@
microsoft.com")) microsoft.com"))
(do))) (do)))
(defn create-dirs
"Create all directories needed for a file (mkdir -p)."
[dest]
(def segs (string/split "/" dest))
(for i 1 (length segs)
(def path (string/join (slice segs 0 i) "/"))
(unless (empty? path) (os/mkdir path))))
# #
# Importing a file # Importing a file
# #
@ -244,6 +236,14 @@
"split paths on / and \\." "split paths on / and \\."
(peg/compile ~(any (* '(any (if-not (set `\/`) 1)) (+ (set `\/`) -1))))) (peg/compile ~(any (* '(any (if-not (set `\/`) 1)) (+ (set `\/`) -1)))))
(defn create-dirs
"Create all directories needed for a file (mkdir -p)."
[dest]
(def segs (peg/match path-splitter dest))
(for i 1 (length segs)
(def path (string/join (slice segs 0 i) sep))
(unless (empty? path) (os/mkdir path))))
(def- filepath-replacer (def- filepath-replacer
"Convert url with potential bad characters into a file path element." "Convert url with potential bad characters into a file path element."
(peg/compile ~(% (any (+ (/ '(set "<>:\"/\\|?*") "_") '1))))) (peg/compile ~(% (any (+ (/ '(set "<>:\"/\\|?*") "_") '1)))))