Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a binary stream (not a file) in Common Lisp?

I have a function which output some binary data to a stream. But the stream is abstract, which means the stream can be a file stream, or some other streams. But the stream must be a binary stream which support write-byte function. I searched but not found the answer.

What I want to do is, I have a function which will convert some data to a gif. But I donot want to output the data to a file, I want to output it to something in memory.

Thanks.

like image 230
kevin lynx Avatar asked Sep 16 '11 08:09

kevin lynx


2 Answers

The flexi-streams library provides, among other things, in-memory binary streams.

like image 98
Ramarren Avatar answered Sep 29 '22 06:09

Ramarren


"File in memory" - is just a byte array. So all you need is to read your data from stream and write it to one-dimensional array (vector). For more information on arrays in CL see this.

like image 32
ffriend Avatar answered Sep 29 '22 06:09

ffriend