Created
April 18, 2024 23:09
-
-
Save ruseel/862ba31cccd7ee60e12698a733d0d383 to your computer and use it in GitHub Desktop.
What file is raising MalformedInputException on slurp?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; What file is raising MalformedInputException on slurp? | |
(use 'clojure.java.io) | |
(import 'java.nio.file.Files) | |
(import 'java.nio.file.Paths) | |
(import 'java.nio.charset.MalformedInputException) | |
(def directory? (memfn isDirectory)) | |
(def name (memfn getName)) | |
(def ->nbr #(Files/newBufferedReader (Paths/get (.toURI %)))) | |
(defn malformed? [f] (try (slurp (->nbr f)) nil (catch MalformedInputException e f))) | |
(def files (file-seq (file "."))) | |
(transduce (comp | |
(filter directory?) | |
(filter (comp (partial re-seq #"resources|xyz") name)) | |
(mapcat file-seq) | |
(filter (comp not directory?)) | |
(filter malformed?)) | |
conj | |
files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment