[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binary i/o



I tried writing a binary file and reading it back in.
What seems to happen is that you wind up reading
past the end of file.
(WRITE-BINARY-FILE) followed by (READ-BINARY-FILE)
returns a list with the stuff written and a lot of extraneous garbage 
at the end.


(EVAL-WHEN (EVAL LOAD COMPILE)
	   (COND ((NOT (STATUS FEATURE LOOP)) (LOAD "liblsp;loop") (SSTATUS FEATURE LOOP))))

(DEFUN READ-BINARY-FILE ()
       (LET ((FILE (OPEN "henry;use less" '(READ FIXNUM))))
	    (LOOP FOR NEXT-WORD =  (TYI FILE 'END-OF-FILE)
		  UNTIL (EQ NEXT-WORD 'END-OF-FILE)
		  COLLECT NEXT-WORD)))

(DEFUN WRITE-BINARY-FILE ()
       (LET ((A-FILE (OPEN "henry;use less" '(WRITE FIXNUM))))
	    (TYO 17. A-FILE)
	    (TYO 69. A-FILE)
	    (CLOSE A-FILE)))