Allow load-file function to specify the buffer's type
This commit is contained in:
parent
7eaca6a359
commit
563bd7f0f9
1 changed files with 6 additions and 6 deletions
|
|
@ -10,16 +10,16 @@
|
|||
(:export :load-file))
|
||||
(in-package :stoe.file)
|
||||
|
||||
(defun do-load-file (filepath)
|
||||
(defun do-load-file (filepath type)
|
||||
"Load the file specified by `filepath' and store it in the object returned."
|
||||
(with-open-file (stream filepath :direction :input :element-type '(unsigned-byte 8))
|
||||
(with-open-file (stream filepath :direction :input :element-type type)
|
||||
(when stream
|
||||
(let ((buffer (make-array (file-length stream) :element-type '(unsigned-byte 8))))
|
||||
(let ((buffer (make-array (file-length stream) :element-type type)))
|
||||
(read-sequence buffer stream)
|
||||
buffer))))
|
||||
|
||||
(defun load-file (filepath callback &key (sync nil))
|
||||
(defun load-file (filepath &key (sync nil) (type '(unsigned-byte 8)))
|
||||
"Load the file specified by `filepath' asynchronally unless `sync' is true."
|
||||
(if sync
|
||||
(callback (do-load-file filepath))
|
||||
(jobs:push-job #'do-load-file (list filepath) callback)))
|
||||
(do-load-file filepath type)
|
||||
(jobs:push-job #'do-load-file (list filepath type))))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue