[gambit-list] Reading binary files
Bob McIsaac
bobmc at fcibroadband.com
Tue Dec 18 22:31:03 EST 2007
Siegfried Gonzi wrote:
> Hello:
>
> Is there an easy way in Gambit to read binary files? I have got binary files created on my desktop Linux machine Thanks very much,
> Siegfried Gonzi
>
Hello, following is a routine I tried.. It works but is probably slow
since it includes
byte-by-byte I/O reads.
Why not use a C library and the FFI? It would give you an abstraction
boundary
with separation from hardware or architecture concerns. And could be
designed
to bind with any high-level language.
regards, Bob
-----------------------------------------
(define (integer-in )
(set! *filesize* (- *filesize* 4))
(bitwise-ior
(bitwise-and (arithmetic-shift (read-u8 INP) 24) #xff000000)
(bitwise-and (arithmetic-shift (read-u8 INP) 16) #xff0000)
(bitwise-and (arithmetic-shift (read-u8 INP) 8) #xff00)
(bitwise-and (read-u8 INP) #xff)))
More information about the Gambit-list
mailing list