Function: jka-compr-partial-uncompress
jka-compr-partial-uncompress is a byte-compiled function defined in
jka-compr.el.gz.
Signature
(jka-compr-partial-uncompress PROG MESSAGE ARGS INFILE BEG LEN)
Documentation
Call program PROG with ARGS args taking input from INFILE.
Fourth and fifth args, BEG and LEN, specify which part of the output to keep: LEN chars starting BEG chars from the beginning.
Source Code
;; Defined in /usr/src/emacs/lisp/jka-compr.el.gz
(defun jka-compr-partial-uncompress (prog message args infile beg len)
"Call program PROG with ARGS args taking input from INFILE.
Fourth and fifth args, BEG and LEN, specify which part of the output
to keep: LEN chars starting BEG chars from the beginning."
(let ((start (point))
(prefix beg))
(if (and jka-compr-use-shell jka-compr-dd-program)
;; Put the uncompression output through dd
;; to discard the part we don't want.
(let ((skip (/ beg jka-compr-dd-blocksize))
(err-file (jka-compr-make-temp-name))
;; call-process barfs if default-directory is inaccessible.
(default-directory
(if (and default-directory
(file-accessible-directory-p default-directory))
default-directory
(file-name-directory infile)))
count)
;; Update PREFIX based on the text that we won't read in.
(setq prefix (- beg (* skip jka-compr-dd-blocksize))
count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize))))
(unwind-protect
(or (memq (call-process
jka-compr-shell infile t nil "-c"
;; Windows shells need the program file name
;; after the pipe symbol be quoted if they use
;; forward slashes as directory separators.
(format
"%s %s 2> %s | \"%s\" bs=%d skip=%d %s 2> %s"
prog
(mapconcat #'identity args " ")
err-file
jka-compr-dd-program
jka-compr-dd-blocksize
skip
;; dd seems to be unreliable about
;; providing the last block. So, always
;; read one more than you think you need.
(if count (format "count=%d" (1+ count)) "")
null-device))
jka-compr-acceptable-retval-list)
(jka-compr-error prog args infile message err-file))
(delete-file err-file)))
;; Run the uncompression program directly.
;; We get the whole file and must delete what we don't want.
(jka-compr-call-process prog message infile t nil args))
;; Delete the stuff after what we want, if there is any.
(and
len
(< (+ start prefix len) (point))
(delete-region (+ start prefix len) (point)))
;; Delete the stuff before what we want.
(delete-region start (+ start prefix))))