[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Request for general advice on reading binary data
From: |
Hans Bulfone |
Subject: |
Re: [Chicken-users] Request for general advice on reading binary data |
Date: |
Tue, 29 Apr 2008 17:55:51 +0200 |
User-agent: |
Mutt/1.5.16 (2007-06-09) |
hi,
On Tue, Apr 29, 2008 at 06:33:44AM -0700, Matthew Welland wrote:
> I'm using file-open and file-read and various blob to vector conversions to
> read and parse binary files. Does anyone have any general suggestions or
> guidelines for doing this efficiently? One possibility that occured to me
> is to read large chunks into a blob and then process rather than reading
> small chunks as needed. I'll probably give this a try but I'm hoping to
> save exploring dead ends by tapping the wisdom of this group.
if your data can be represented as c-structs you could read it in some
malloc()ed memory block and then use accessors defined with
define-foreign-record.
or on unix you could mmap() it and then use define-foreign-record
accessors.
but this only works if the file really is laid out like a c struct
(and thus is not very platform independent).
i like peter seibel's binary file library in practical common lisp[1],
i always wanted to write something like that for chicken, but didn't
do it so far :(
hth&bye,
hans.
[1] http://www.gigamonkeys.com/book/practical-parsing-binary-files.html