Skip to content
This repository
  • 7 commits
  • 2 files changed
  • 0 comments
  • 2 contributors
Apr 10, 2012
Wolodja Wentland babilen Add absolute? function
absolute? returns true if given path is absolute.
3214cd3
Wolodja Wentland babilen Add function to join paths 6e643d4
Wolodja Wentland babilen Add find-files function
find-files returns paths of those files beneath a directory that match given
pattern.
eeb8f6b
Wolodja Wentland babilen Fix typo 788a94a
Wolodja Wentland babilen Remove join function f322981
Wolodja Wentland babilen Return java.io.Files from find-files bdffcfa
Anthony Grimes Remove join tests. 28059a4

Showing 2 changed files with 20 additions and 1 deletion. Show diff stats Hide diff stats

  1. +13 1 src/fs/core.clj
  2. +7 0 test/fs/core_test.clj
14 src/fs/core.clj
@@ -65,6 +65,11 @@
65 65 [path]
66 66 (seq (.list (file path))))
67 67
  68 +(defn absolute?
  69 + "Return true if path is absolute."
  70 + [path]
  71 + (.isAbsolute (io/file path)))
  72 +
68 73 (defn executable?
69 74 "Return true if path is executable."
70 75 [path]
@@ -383,7 +388,7 @@ If 'trim-ext' is true, any extension is trimmed."
383 388 [p c] (some #{(file p)} (parents c)))
384 389
385 390 (defn ns-path
386   - "Takes a namespace symbol and creates a path to it. Replaces hypens with
  391 + "Takes a namespace symbol and creates a path to it. Replaces hyphens with
387 392 underscores. Assumes the path should be relative to cwd."
388 393 [n]
389 394 (file
@@ -400,3 +405,10 @@ If 'trim-ext' is true, any extension is trimmed."
400 405 (.. (.replaceAll (str path) "\\.clj" "")
401 406 (replace \_ \-)
402 407 (replace \/ \.))))
  408 +
  409 +(defn find-files
  410 + "Find files matching given pattern."
  411 + [path pattern]
  412 + (for [f (-> path file file-seq)
  413 + :when (re-matches pattern (.getName f))]
  414 + f))
7 test/fs/core_test.clj
@@ -287,3 +287,10 @@
287 287
288 288 (fact
289 289 (str (ns-path 'foo.bar.baz-quux)) => (has-suffix "foo/bar/baz_quux.clj"))
  290 +
  291 +(fact
  292 + (absolute? "/foo/bar") => true
  293 + (absolute? "/foo/") => true
  294 + (absolute? "foo/bar") => false
  295 + (absolute? "foo/") => false)
  296 +

No commit comments for this range

Something went wrong with that request. Please try again.