Advertisement
Faed

Slow in ECL

Sep 18th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.97 KB | None | 0 0
  1. (defparameter *what-we-already-have* (make-hash-table :test #'equal))
  2.  
  3. (defparameter *aggregate-storage-directory*
  4.   (ensure-directories-exist
  5.    (merge-pathnames
  6.     (format nil "Desktop_pics/dpool/")
  7.     (user-homedir-pathname))))
  8.  
  9. (defun sha1-file (path)
  10.   (let ((sha1 (ironclad:make-digest 'ironclad:sha1)))
  11.     (with-open-file (stream path :element-type '(unsigned-byte 8))
  12.       (ironclad:update-digest sha1 stream)
  13.       (values (ironclad:byte-array-to-hex-string (ironclad:produce-digest sha1)) path))))
  14.  
  15. (defun load-pool (&key (path *aggregate-storage-directory*))
  16.   ;; for every file in the given directory (path), calculate its hash
  17.   ;; and put it in the special table
  18.   (loop for file in (uiop:directory-files path)
  19.         for (hash path) = (multiple-value-list (sha1-file file))
  20.         :do (progn
  21.               (format t "~&~A :: ~A" hash path)
  22.               (setf (gethash hash *what-we-already-have*) path)
  23.               (format t "     [Done]"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement