(read-byte$-all channel state) reads all remaining bytes from a file.
This is the main loop inside read-file-bytes. It reads everything in the file, but doesn't handle opening or closing the file.
Function:
(defun tr-read-byte$-all (channel state acc) (declare (xargs :guard (and (state-p state) (symbolp channel) (open-input-channel-p channel :byte state)))) (b* (((unless (mbt (state-p state))) (mv acc state)) ((mv byte state) (read-byte$ channel state)) ((unless byte) (mv acc state)) (acc (cons (mbe :logic (if (unsigned-byte-p 8 byte) byte 0) :exec byte) acc))) (tr-read-byte$-all channel state acc)))
Function:
(defun read-byte$-all (channel state) (declare (xargs :guard (and (state-p state) (symbolp channel) (open-input-channel-p channel :byte state)))) (mbe :logic (b* (((unless (state-p state)) (mv nil state)) ((mv byte state) (read-byte$ channel state)) ((unless byte) (mv nil state)) ((mv rest state) (read-byte$-all channel state)) (byte (if (unsigned-byte-p 8 byte) byte 0))) (mv (cons byte rest) state)) :exec (b* (((mv contents state) (tr-read-byte$-all channel state nil))) (mv (reverse contents) state))))
Theorem:
(defthm tr-read-byte$-all-removal (equal (tr-read-byte$-all channel state nil) (mv (rev (mv-nth 0 (read-byte$-all channel state))) (mv-nth 1 (read-byte$-all channel state)))))
Theorem:
(defthm true-listp-of-read-byte$-all (true-listp (mv-nth 0 (read-byte$-all channel state))) :rule-classes :type-prescription)
Theorem:
(defthm state-p1-of-read-byte$-all (implies (and (force (state-p1 state)) (force (symbolp channel)) (force (open-input-channel-p1 channel :byte state))) (state-p1 (mv-nth 1 (read-byte$-all channel state)))))
Theorem:
(defthm open-input-channel-p1-of-read-byte$-all (implies (and (force (state-p1 state)) (force (symbolp channel)) (force (open-input-channel-p1 channel :byte state))) (open-input-channel-p1 channel :byte (mv-nth 1 (read-byte$-all channel state)))))
Theorem:
(defthm integer-listp-of-read-byte$-all (integer-listp (mv-nth 0 (read-byte$-all channel state))))
Theorem:
(defthm nat-listp-of-read-byte$-all (nat-listp (mv-nth 0 (read-byte$-all channel state))))
Theorem:
(defthm unsigned-byte-listp-of-read-byte$-all (unsigned-byte-listp 8 (mv-nth 0 (read-byte$-all channel state))))