+;;; SEMI-KLUDGE: Preferable would be to use something like O_NOFOLLOW
+;;; which will refuse to open() a file if it is a symlink; but I've
+;;; been told that is a FreeBSD/Linux-only thing. Meanwhile, this will
+;;; make our filenames a lot less predictable.
+;;; (The man file for open() says O_EXCL should treat even a symlink as
+;;; an existing file. I wonder if it really does that.)
+;;; Also, no more dependence on ASCII character ordering.
+;;; -- mrd 20021101
+(defun generate-random-string (&optional (len 6))
+ (let* ((characters "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+ (num (length characters))
+ (string (make-string len)))
+ (dotimes (i len string)
+ (setf (char string i)
+ (char characters (random num))))))
+