Advertisement
Guest User

Untitled

a guest
Feb 28th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   (let [kraw (kwork/genkey)
  2.         jumbled-key (kwork/jumble kraw)
  3.         index (io/file index-file)
  4.         dump (io/file dump-file)
  5.         index-f (io/file index-final)
  6.         dump-f (io/file dump-final)
  7.         tmp-index (java.io.File/createTempFile "ussa__11_" "90001__"
  8.                                                (.getParentFile index))
  9.         tmp-dump (java.io.File/createTempFile "ussa__11_" "90001__"
  10.                                               (.getParentFile dump))]
  11.     [(try
  12.         (do
  13.           (.createNewFile index-f)
  14.           (.createNewFile dump-f)
  15.           (.deleteOnExit index)
  16.           (.deleteOnExit dump)
  17.           (with-open [index-is (io/input-stream index)
  18.                       tmpindex-os (io/output-stream tmp-index)]
  19.             (.write tmpindex-os jumbled-key 0 (alength jumbled-key)) ;; write key
  20.             (kwork/encf index-is tmpindex-os kraw) ;; write dump contents
  21.             (.renameTo tmp-index index-f))
  22.           (with-open [dump-is (io/input-stream dump)
  23.                       tmpdump-os (io/output-stream tmp-dump)]
  24.             (kwork/encf dump-is tmpdump-os kraw)
  25.             (.renameTo tmp-dump dump-f)))
  26.           )
  27.      (catch Exception e (println (str "EXCEPTION " e))))]
  28.     (do
  29.       (System/gc)
  30.       (.renameTo tmp-index index-f)
  31.       (.renameTo tmp-dump dump-f))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement