mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
Adding maybe-gunzip utility for optionally compressed inputs.
This commit is contained in:
parent
c3b265f990
commit
a21e391f15
2 changed files with 11 additions and 1 deletions
|
@ -35,3 +35,13 @@
|
|||
|
||||
(define (gunzip bvec)
|
||||
(process-pipe-bytevector '("gzip" "-c" "-d") bvec))
|
||||
|
||||
;;> Gunzip decompress a bytevector in memory if it has been
|
||||
;;> compressed, or return as-is otherwise.
|
||||
|
||||
(define (maybe-gunzip bvec)
|
||||
(if (and (>= (bytevector-length bvec) 10)
|
||||
(eqv? #x1f (bytevector-u8-ref bvec 0))
|
||||
(eqv? #x8b (bytevector-u8-ref bvec 1)))
|
||||
(gunzip bvec)
|
||||
bvec))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
(define-library (chibi zlib)
|
||||
(export gzip-file gunzip-file gzip gunzip)
|
||||
(export gzip-file gunzip-file gzip gunzip maybe-gunzip)
|
||||
(import (scheme base) (chibi io) (chibi process))
|
||||
(include "zlib.scm"))
|
||||
|
|
Loading…
Add table
Reference in a new issue