aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/jka-compr.el80
1 files changed, 41 insertions, 39 deletions
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index 8c107cc3271..32df6ce53f9 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -155,6 +155,12 @@ to keep: LEN chars starting BEG chars from the beginning."
155 ;; to discard the part we don't want. 155 ;; to discard the part we don't want.
156 (let ((skip (/ beg jka-compr-dd-blocksize)) 156 (let ((skip (/ beg jka-compr-dd-blocksize))
157 (err-file (jka-compr-make-temp-name)) 157 (err-file (jka-compr-make-temp-name))
158 ;; call-process barfs if default-directory is inaccessible.
159 (default-directory
160 (if (and default-directory
161 (file-accessible-directory-p default-directory))
162 default-directory
163 (file-name-directory infile)))
158 count) 164 count)
159 ;; Update PREFIX based on the text that we won't read in. 165 ;; Update PREFIX based on the text that we won't read in.
160 (setq prefix (- beg (* skip jka-compr-dd-blocksize)) 166 (setq prefix (- beg (* skip jka-compr-dd-blocksize))
@@ -193,45 +199,41 @@ to keep: LEN chars starting BEG chars from the beginning."
193 199
194 200
195(defun jka-compr-call-process (prog message infile output temp args) 201(defun jka-compr-call-process (prog message infile output temp args)
196 (if jka-compr-use-shell 202 ;; call-process barfs if default-directory is inaccessible.
197 203 (let ((default-directory
198 (let ((err-file (jka-compr-make-temp-name)) 204 (if (and default-directory
199 (coding-system-for-read (or coding-system-for-read 'undecided)) 205 (file-accessible-directory-p default-directory))
200 (coding-system-for-write 'no-conversion)) 206 default-directory
201 207 (file-name-directory infile))))
202 (unwind-protect 208 (if jka-compr-use-shell
203 209 (let ((err-file (jka-compr-make-temp-name))
204 (or (memq 210 (coding-system-for-read (or coding-system-for-read 'undecided))
205 (call-process jka-compr-shell infile 211 (coding-system-for-write 'no-conversion))
206 (if (stringp output) nil output) 212 (unwind-protect
207 nil 213 (or (memq
208 "-c" 214 (call-process jka-compr-shell infile
209 (format "%s %s 2> %s %s" 215 (if (stringp output) nil output)
210 prog 216 nil
211 (mapconcat 'identity args " ") 217 "-c"
212 err-file 218 (format "%s %s 2> %s %s"
213 (if (stringp output) 219 prog
214 (concat "> " output) 220 (mapconcat 'identity args " ")
215 ""))) 221 err-file
216 jka-compr-acceptable-retval-list) 222 (if (stringp output)
217 223 (concat "> " output)
218 (jka-compr-error prog args infile message err-file)) 224 "")))
219 225 jka-compr-acceptable-retval-list)
220 (jka-compr-delete-temp-file err-file))) 226 (jka-compr-error prog args infile message err-file))
221 227 (jka-compr-delete-temp-file err-file)))
222 (or (eq 0 228 (or (eq 0
223 (apply 'call-process 229 (apply 'call-process
224 prog 230 prog infile (if (stringp output) temp output)
225 infile 231 nil args))
226 (if (stringp output) temp output) 232 (jka-compr-error prog args infile message))
227 nil 233 (and (stringp output)
228 args)) 234 (with-current-buffer temp
229 (jka-compr-error prog args infile message)) 235 (write-region (point-min) (point-max) output)
230 236 (erase-buffer))))))
231 (and (stringp output)
232 (with-current-buffer temp
233 (write-region (point-min) (point-max) output)
234 (erase-buffer)))))
235 237
236 238
237;; Support for temp files. Much of this was inspired if not lifted 239;; Support for temp files. Much of this was inspired if not lifted