|
45 | 45 | (defn probable-license-files
|
46 | 46 | "Returns all probable license files in the given directory, recursively, as a
|
47 | 47 | set of java.io.File objects. dir may be a String or a java.io.File, either of
|
48 |
| - which must refer to a readable directory." |
49 |
| - [dir] |
50 |
| - (when (lciu/readable-dir? dir) |
51 |
| - (some-> (seq (filter #(and (.isFile ^java.io.File %) (probable-license-file? %)) (file-seq (io/file dir)))) |
52 |
| - set))) |
| 48 | + which must refer to a readable directory. By default ignores hidden |
| 49 | + directories." |
| 50 | + ([dir] (probable-license-files dir false)) |
| 51 | + ([dir include-hidden-dirs?] |
| 52 | + (when (lciu/readable-dir? dir) |
| 53 | + (some-> (lciu/filter-file-only-seq (io/file dir) |
| 54 | + (fn [^java.io.File d] (and (not= (.getCanonicalFile d) (.getCanonicalFile (io/file (lcmvn/local-maven-repo)))) ; Make sure to exclude the Maven local repo, just in case it happens to be nested within dir |
| 55 | + (or include-hidden-dirs? (not (.isHidden d))))) |
| 56 | + probable-license-file?) |
| 57 | + set)))) |
53 | 58 |
|
54 | 59 | (defn file->expressions-info
|
55 | 60 | "Returns an expressions-info map for the given file (an InputStream or
|
|
123 | 128 | (defn- zip-compressed-files
|
124 | 129 | "Returns a set of all probable ZIP compressed files (Files) in the given
|
125 | 130 | directory, recursively, or nil if there are none. dir may be a String or a
|
126 |
| - java.io.File, and must refer to a readable directory." |
127 |
| - [dir] |
128 |
| - (when (lciu/readable-dir? dir) |
129 |
| - (some-> (seq (filter #(and (.isFile ^java.io.File %) |
130 |
| - (or (s/ends-with? (str %) ".zip") |
131 |
| - (s/ends-with? (str %) ".jar"))) |
132 |
| - (file-seq (io/file dir)))) |
133 |
| - set))) |
| 131 | + java.io.File, and must refer to a readable directory. By default ignores |
| 132 | + hidden directories." |
| 133 | + ([dir] (zip-compressed-files dir false)) |
| 134 | + ([dir include-hidden-dirs?] |
| 135 | + (when (lciu/readable-dir? dir) |
| 136 | + (some-> (lciu/filter-file-only-seq (io/file dir) |
| 137 | + (fn [^java.io.File d] (or include-hidden-dirs? (not (.isHidden d)))) |
| 138 | + (fn [^java.io.File f] |
| 139 | + (let [lname (s/lower-case (.getName f))] |
| 140 | + (or (s/ends-with? lname ".zip") |
| 141 | + (s/ends-with? lname ".jar"))))) |
| 142 | + set)))) |
134 | 143 |
|
135 | 144 | (defn dir->expressions-info
|
136 | 145 | "Returns an expressions-info map for the given dir (a String or a File,
|
|
0 commit comments