Discussion:
how to use with-open-gzip-file from gzip-stream with :direction :output?
(too old to reply)
Gregory Ramirez
2020-01-28 13:45:22 UTC
Permalink
Could someone give an example of how to use "with-open-gzip-file" from
package gzip-stream?

How would i create a new compressed file "bases.gz" with
"gzip-stream:with-open-gzip-file" to write lisp objects to "bases.gz"?

for instance

(with-open-gzip-file (out "bases.gz" :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write '(a b c) out))

doesn't work.

thanks in advance
t***@google.com
2020-01-28 16:38:15 UTC
Permalink
Post by Gregory Ramirez
Could someone give an example of how to use "with-open-gzip-file" from
package gzip-stream?
...
Post by Gregory Ramirez
(with-open-gzip-file (out "bases.gz" :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(write '(a b c) out))
doesn't work.
How does it not work?
Do you get an error message?
Or does it return normally and just not write the file?
Does it work if you (write "some string" out)?
Have you tried using (make-gzip-output-stream stream) and (gzip-sequence sequence)?
Gregory Ramirez
2020-01-28 20:58:13 UTC
Permalink
On Tuesday, January 28, 2020 at 5:45:28 AM UTC-8, Gregory Ramirez
wrote: [...]
...
[...]
How does it not work?
Do you get an error message?
Or does it return normally and just not write the file?
Does it work if you (write "some string" out)?
Have you tried using (make-gzip-output-stream stream) and
(gzip-sequence sequence)?
Trying

(with-open-gzip-file (f "bases.gz")
:direction :output :if-exists :supersede
:if-does-not-exist :create)
(write '(a b c) :stream f))

gives me an error message (using sbcl/slime):

There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION SB-GRAY:STREAM-WRITE-STRING (4)>
"(A B
C)^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^\
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@" 0 7).
[Condition of type SB-PCL::NO-APPLICABLE-METHOD-ERROR]
See also:
Common Lisp Hyperspec, 7.6.6 [:section]

Same with "abc" instead of '(a b c).

I tried to avoid make-gzip-output-stream because i don't know how to
use it.

Here's my try:

(with-open-file (f "bases.gz" :direction :output
:if-exists :supersede
:if-does-not-exist :create)
(let ((gzip-out (gzip-stream:make-gzip-output-stream f)))
(write '(a b c) :stream gzip-out)))

==> same error as above.
t***@google.com
2020-01-28 23:21:55 UTC
Permalink
Post by Gregory Ramirez
Post by t***@google.com
Do you get an error message?
Trying
(with-open-gzip-file (f "bases.gz")
:direction :output :if-exists :supersede
:if-does-not-exist :create)
(write '(a b c) :stream f))
There is no applicable method for the generic function
#<STANDARD-GENERIC-FUNCTION SB-GRAY:STREAM-WRITE-STRING (4)>
"(A B
@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@" 0 7).
[Condition of type SB-PCL::NO-APPLICABLE-METHOD-ERROR]
Common Lisp Hyperspec, 7.6.6 [:section]
Looks like it is missing some items for working with SBCL. You might need to
try contacting the author, Sean Ross. Try sross at common-lisp.net and see if
he responds.
Gregory Ramirez
2020-02-13 14:39:51 UTC
Permalink
Post by t***@google.com
[...]
[...]
Looks like it is missing some items for working with SBCL. You might
need to try contacting the author, Sean Ross. Try sross at
common-lisp.net and see if he responds.
Here is an example how i use gzip-stream as intended using Peter
Seibel's binary-data library:

(gzip-stream:with-open-gzip-file (out f :direction :output)
(binary-io:write-value
'binary-io.common-datatypes:iso-8859-1-string
out
"(1 2 3)"
:length (length "(1 2 3)"))

Loading...