Skip to content
Browse files

Started some tests or clj-file-utils, not sure about that lib...

  • Loading branch information...
1 parent 60c4a2d commit fd5f61869eadb46de90b60f4c3cd3212a6563d4d @mmcgrana committed Jan 16, 2009
View
2 clj-file-utils/README.textile
@@ -14,5 +14,5 @@ h2. Implemented Functions
rm-r
rm-rf
touch
- mkdirp
+ mkdir-p
chmod
View
8 clj-file-utils/src/clj_file_utils/core.clj
@@ -11,6 +11,11 @@
([parent name] (File. parent name))
([p q & names] (reduce file (file p q) names)))
+(defn exist
+ "Returns true if the file exists"
+ [#^File file]
+ (.exists file))
+
(defn size
"Returns the size in bytes of a file."
[#^File file]
@@ -68,6 +73,7 @@
(FileUtils/forceMkdir file)))
(defn chmod
- "'chmod' a file to a mode given as a 4-character string."
+ "'chmod' a file to a mode given as a 4-character string. Only works on
+ system with a chmod command."
[#^File file #^String mode]
(sh "chmod" mode (.getAbsolutePath file)))
View
0 clj-file-utils/test/clj_file_utils/assets/foo.txt
No changes.
View
12 clj-file-utils/test/clj_file_utils/core_test.clj
@@ -0,0 +1,12 @@
+(ns clj-file-utils.core-test
+ (:use clj-unit.core clj-file-utils.core)
+ (:import java.io.File))
+
+(def foo (File. "test/clj_file_utils/assets/foo.txt"))
+
+(deftest "file"
+ (assert= foo (file "test/clj_file_utils/assets/foo.txt"))
+ (assert= foo (file (file "test/clj_file_utils/assets") "foo.txt"))
+ (assert= foo (file "test" "clj_file_utils" "assets" "foo.txt")))
+
+(run-tests 'clj-file-utils.core-test)

0 comments on commit fd5f618

Please sign in to comment.
Something went wrong with that request. Please try again.