unzip: Handle non-seekable input ports.

Before this commit:
  - unzip would attempt to seek the input port via file-position in some cases

After this commit:
  - unzip reads and discards bytes as needed to skip forward
This commit is contained in:
Marc Burns 2014-08-31 18:36:05 -04:00 committed by Matthew Flatt
parent c9692b113f
commit 478b01b0e3
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#lang racket/base
(require file/unzip
racket/runtime-path
racket/port
tests/eli-tester)
(define-runtime-path unzip-me.zip "unzip-me.zip")
@ -24,6 +25,8 @@
(define (run-tests)
(test-with-unzip unzip-me.zip)
(call-with-input-file* unzip-me.zip test-with-unzip)
(call-with-input-file* unzip-me.zip
(lambda(in_port) (test-with-unzip (input-port-append #f in_port))))
(test-with-unzip-entry))
(provide tests)

View File

@ -217,7 +217,7 @@
;; is immediately followed by a data descriptor
(if (bitwise-bit-set? bits 3)
(skip-bytes 12 in)
(file-position in (+ mark compressed))))))
(skip-bytes (- (+ mark compressed) (file-position in)) in)))))
(void))))
;; find-central-directory : input-port nat -> nat nat nat