172 |
(1+ thumbs-gensym-counter)))))) |
(1+ thumbs-gensym-counter)))))) |
173 |
(make-symbol (format "%s%d" pfix num)))))) |
(make-symbol (format "%s%d" pfix num)))))) |
174 |
|
|
175 |
|
(defsubst thumbs-temp-dir () |
176 |
|
(file-name-as-directory (expand-file-name thumbs-temp-dir))) |
177 |
|
|
178 |
(defun thumbs-temp-file () |
(defun thumbs-temp-file () |
179 |
"Return a unique temporary filename for an image." |
"Return a unique temporary filename for an image." |
180 |
(format "%s%s-%s.jpg" |
(format "%s%s-%s.jpg" |
181 |
(expand-file-name thumbs-temp-dir) |
(thumbs-temp-dir) |
182 |
thumbs-temp-prefix |
thumbs-temp-prefix |
183 |
(thumbs-gensym "T"))) |
(thumbs-gensym "T"))) |
184 |
|
|
185 |
(defun thumbs-thumbsdir () |
(defun thumbs-thumbsdir () |
186 |
"Return the current thumbnails directory (from `thumbs-thumbsdir'). |
"Return the current thumbnails directory (from `thumbs-thumbsdir'). |
187 |
Create the thumbnails directory if it does not exist." |
Create the thumbnails directory if it does not exist." |
188 |
(let ((thumbs-thumbsdir (expand-file-name thumbs-thumbsdir))) |
(let ((thumbs-thumbsdir (file-name-as-directory |
189 |
|
(expand-file-name thumbs-thumbsdir)))) |
190 |
(unless (file-directory-p thumbs-thumbsdir) |
(unless (file-directory-p thumbs-thumbsdir) |
191 |
(make-directory thumbs-thumbsdir) |
(make-directory thumbs-thumbsdir) |
192 |
(message "Creating thumbnails directory")) |
(message "Creating thumbnails directory")) |
271 |
(condition-case nil |
(condition-case nil |
272 |
(apply 'delete-file |
(apply 'delete-file |
273 |
(directory-files |
(directory-files |
274 |
thumbs-temp-dir t |
(thumbs-temp-dir) t |
275 |
thumbs-temp-prefix)) |
thumbs-temp-prefix)) |
276 |
(error nil)) |
(error nil)) |
277 |
(let ((buffer-read-only nil) |
(let ((buffer-read-only nil) |
310 |
"Return a thumbnail name for the image IMG." |
"Return a thumbnail name for the image IMG." |
311 |
(convert-standard-filename |
(convert-standard-filename |
312 |
(let ((filename (expand-file-name img))) |
(let ((filename (expand-file-name img))) |
313 |
(format "%s/%08x-%s.jpg" |
(format "%s%08x-%s.jpg" |
314 |
(thumbs-thumbsdir) |
(thumbs-thumbsdir) |
315 |
(sxhash filename) |
(sxhash filename) |
316 |
(subst-char-in-string |
(subst-char-in-string |
641 |
;; cleaning of old temp file |
;; cleaning of old temp file |
642 |
(mapc 'delete-file |
(mapc 'delete-file |
643 |
(directory-files |
(directory-files |
644 |
thumbs-temp-dir |
(thumbs-temp-dir) |
645 |
t |
t |
646 |
thumbs-temp-prefix)) |
thumbs-temp-prefix)) |
647 |
(let ((buffer-read-only nil) |
(let ((buffer-read-only nil) |