-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimpl.clj
More file actions
25 lines (23 loc) · 757 Bytes
/
Copy pathimpl.clj
File metadata and controls
25 lines (23 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns datomic-local-tu.internal.impl
(:require [clojure.java.io :as io])
(:import (java.nio.file Files SimpleFileVisitor FileVisitResult)
(java.security SecureRandom)
(java.util Base64)))
(defn delete-directory!
[f]
(Files/walkFileTree
(.toPath (io/file f))
(proxy [SimpleFileVisitor] []
(visitFile [path attrs]
(Files/delete path)
FileVisitResult/CONTINUE)
(postVisitDirectory [path io-ex]
(Files/delete path)
FileVisitResult/CONTINUE))))
(let [random (SecureRandom.)
encoder (.withoutPadding (Base64/getUrlEncoder))]
(defn rand-str!
[length]
(let [buffer (byte-array length)
_ (.nextBytes random buffer)]
(.encodeToString encoder buffer))))