Created
March 31, 2022 06:17
-
-
Save saidone75/46460c7b0b7dc4915e415a6e9cd27f0a to your computer and use it in GitHub Desktop.
Get file attribute in Clojure using java.nio
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
(:import [java.nio.file Files FileSystems LinkOption]) | |
(defn file-attribute | |
"Return the value of the specified `attribute` of the file at `file-path` | |
in the current default file system. The argument `attribute` may be passed | |
as a keyword or a string, but must be an attribute name understood be | |
`java.nio.file.Files`." | |
[file-path attribute] | |
(Files/getAttribute | |
(.getPath | |
(FileSystems/getDefault) | |
(str file-path) | |
(into-array java.lang.String [])) | |
(name attribute) | |
(into-array LinkOption []))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment