- (with-output-to-string (out)
- (with-open-file (in file :direction :input)
- (read-stream-to-string in))))
+ (with-open-file (in file :direction :input)
+ (read-stream-to-string in)))
+
+(defun read-file-to-usb8-array (file)
+ "Opens a reads a file. Returns the contents as single unsigned-byte array"
+ (with-open-file (in file :direction :input :element-type '(unsigned-byte 8))
+ (let* ((file-len (file-length in))
+ (usb8 (make-array file-len :element-type '(unsigned-byte 8)))
+ (pos (read-sequence usb8 in)))
+ (unless (= file-len pos)
+ (error "Length read (~D) doesn't match file length (~D)~%" pos file-len))
+ usb8)))
+