Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 7 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 10, 2012
@babilen babilen Add absolute? function
absolute? returns true if given path is absolute.
3214cd3
@babilen babilen Add function to join paths 6e643d4
@babilen babilen Add find-files function
find-files returns paths of those files beneath a directory that match given
pattern.
eeb8f6b
@babilen babilen Fix typo 788a94a
@babilen babilen Remove join function f322981
@babilen babilen Return java.io.Files from find-files bdffcfa
@Raynes Remove join tests. 28059a4
Showing with 20 additions and 1 deletion.
  1. +13 −1 src/fs/core.clj
  2. +7 −0 test/fs/core_test.clj
View
14 src/fs/core.clj
@@ -65,6 +65,11 @@
[path]
(seq (.list (file path))))
+(defn absolute?
+ "Return true if path is absolute."
+ [path]
+ (.isAbsolute (io/file path)))
+
(defn executable?
"Return true if path is executable."
[path]
@@ -383,7 +388,7 @@ If 'trim-ext' is true, any extension is trimmed."
[p c] (some #{(file p)} (parents c)))
(defn ns-path
- "Takes a namespace symbol and creates a path to it. Replaces hypens with
+ "Takes a namespace symbol and creates a path to it. Replaces hyphens with
underscores. Assumes the path should be relative to cwd."
[n]
(file
@@ -400,3 +405,10 @@ If 'trim-ext' is true, any extension is trimmed."
(.. (.replaceAll (str path) "\\.clj" "")
(replace \_ \-)
(replace \/ \.))))
+
+(defn find-files
+ "Find files matching given pattern."
+ [path pattern]
+ (for [f (-> path file file-seq)
+ :when (re-matches pattern (.getName f))]
+ f))
View
7 test/fs/core_test.clj
@@ -287,3 +287,10 @@
(fact
(str (ns-path 'foo.bar.baz-quux)) => (has-suffix "foo/bar/baz_quux.clj"))
+
+(fact
+ (absolute? "/foo/bar") => true
+ (absolute? "/foo/") => true
+ (absolute? "foo/bar") => false
+ (absolute? "foo/") => false)
+

No commit comments for this range

Something went wrong with that request. Please try again.