Commit 700ed97b authored by Attila Lendvai's avatar Attila Lendvai
Browse files

added read-file-into-byte-vector and write-byte-vector-into-file (until io.lisp's fate is decided)

parent 61cc0148
......@@ -77,6 +77,24 @@ unless it's NIL, which means the system default."
:external-format external-format)
(write-sequence string file-stream)))
(defun read-file-into-byte-vector (pathname)
"Read PATHNAME into a freshly allocated (unsigned-byte 8) vector."
(with-input-from-file (stream pathname :element-type '(unsigned-byte 8))
(let ((length (file-length stream)))
(assert length)
(let ((result (make-array length :element-type '(unsigned-byte 8))))
(read-sequence result stream)
(defun write-byte-vector-into-file (bytes pathname &key (if-exists :error)
(check-type bytes (vector (unsigned-byte 8)))
(with-output-to-file (stream pathname :if-exists if-exists
:if-does-not-exist if-does-not-exist
:element-type '(unsigned-byte 8))
(write-sequence bytes stream)))
(defun copy-file (from to &key (if-to-exists :supersede)
(element-type '(unsigned-byte 8)) finish-output)
(with-input-from-file (input from :element-type element-type)
......@@ -222,6 +222,8 @@
;; new additions collected at the end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment