Skip to content

Commit

Permalink
cljs.io: add .isDirectory and .listFiles methods to File type.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Jan 24, 2013
1 parent ce4889f commit b661eb3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cljs/cljs/io.cljs
Expand Up @@ -137,11 +137,21 @@
(getPath [_]
(path-normalize pathname))

;; Tests whether the file denoted by this abstract pathname is
;; a directory
(isDirectory [me]
(file-is-dir? (.getPath me)))

;; Returns the time that the file denoted by this abstract pathname
;; was last modified
(lastModified [_]
(.getTime (.-mtime (file-stat pathname))))

;; Returns an array of abstract pathnames denoting the files in the
;; directory denoted by this abstract pathname
(listFiles [me]
(file-readdir (.getPath me)))

;; Creates the directory named by this abstract pathname, including
;; any necessary but nonexistent parent directories
(mkdirs [_]
Expand All @@ -165,9 +175,9 @@
[^cljs.io.File dir]
(tree-seq
(fn [^cljs.io.File f]
(file-is-dir? (.getPath f)))
(.isDirectory f))
(fn [^cljs.io.File d]
(map #(cljs.io.File. (str d path-separator %)) (file-readdir (.getPath d))))
(map #(cljs.io.File. (str d path-separator %)) (.listFiles d)))
dir))


0 comments on commit b661eb3

Please sign in to comment.