Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defparameter *what-we-already-have* (make-hash-table :test #'equal))
- (defparameter *aggregate-storage-directory*
- (ensure-directories-exist
- (merge-pathnames
- (format nil "Desktop_pics/dpool/")
- (user-homedir-pathname))))
- (defun sha1-file (path)
- (let ((sha1 (ironclad:make-digest 'ironclad:sha1)))
- (with-open-file (stream path :element-type '(unsigned-byte 8))
- (ironclad:update-digest sha1 stream)
- (values (ironclad:byte-array-to-hex-string (ironclad:produce-digest sha1)) path))))
- (defun load-pool (&key (path *aggregate-storage-directory*))
- ;; for every file in the given directory (path), calculate its hash
- ;; and put it in the special table
- (loop for file in (uiop:directory-files path)
- for (hash path) = (multiple-value-list (sha1-file file))
- :do (progn
- (format t "~&~A :: ~A" hash path)
- (setf (gethash hash *what-we-already-have*) path)
- (format t " [Done]"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement