Hi - <br><br>I am trying to pipe a gzipped file and it seems to hang at the end when I am trying to read the data. It's unclear to me why it hangs at the end (I observed this by seeing it hangs immediately with small files, read quite a bit of data with medium files, and read lots of data with large files before it hangs), and hopefully others can see what I am missing here. <br>
<br>Thanks,<br>yc<br><br>;; gzip.ss <br>#lang scheme/base<br>(require file/gunzip file/gzip mzlib/trace scheme/port)<br><br>(define (open-gzip-file path)<br> (let-values (((in out)<br> (make-pipe-with-specials #f path)))<br>
(thread (lambda ()<br> (call-with-input-file path<br> (lambda (in)<br> (gunzip-through-ports in out)))))<br> in))<br><br>(define (read-bytes* num in)<br> (read-bytes num in))<br>
<br>(trace read-bytes*)<br><br>(define (reader in)<br> (let loop ((b (read-bytes* 4096 in)))<br> (if (eof-object? b)<br> ;; (reverse acc)<br> (void)<br> (loop (read-bytes* 4096 in)))))<br><br>(provide reader open-gzip-file)<br>
<br>;; test ;; uncomment and run the two lines below in REPL <br>;; (require "gzip.ss")<br>;; (reader (open-gzip-file path-to-gzipped-file))<br>;; observe the it eventually hangs on calling read-bytes*.<br><br>