Mercurial > emacs
changeset 75494:04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
default-directory if it is invalid. Suggested by Chris Moore.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 29 Jan 2007 02:51:41 +0000 |
parents | 707654b699b0 |
children | d241328c04c5 |
files | lisp/jka-compr.el |
diffstat | 1 files changed, 41 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/jka-compr.el Mon Jan 29 02:51:28 2007 +0000 +++ b/lisp/jka-compr.el Mon Jan 29 02:51:41 2007 +0000 @@ -155,6 +155,12 @@ ;; 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)) @@ -193,45 +199,41 @@ (defun jka-compr-call-process (prog message infile output temp args) - (if jka-compr-use-shell - - (let ((err-file (jka-compr-make-temp-name)) - (coding-system-for-read (or coding-system-for-read 'undecided)) - (coding-system-for-write 'no-conversion)) - - (unwind-protect - - (or (memq - (call-process jka-compr-shell infile - (if (stringp output) nil output) - nil - "-c" - (format "%s %s 2> %s %s" - prog - (mapconcat 'identity args " ") - err-file - (if (stringp output) - (concat "> " output) - ""))) - jka-compr-acceptable-retval-list) - - (jka-compr-error prog args infile message err-file)) - - (jka-compr-delete-temp-file err-file))) - - (or (eq 0 - (apply 'call-process - prog - infile - (if (stringp output) temp output) - nil - args)) - (jka-compr-error prog args infile message)) - - (and (stringp output) - (with-current-buffer temp - (write-region (point-min) (point-max) output) - (erase-buffer))))) + ;; call-process barfs if default-directory is inaccessible. + (let ((default-directory + (if (and default-directory + (file-accessible-directory-p default-directory)) + default-directory + (file-name-directory infile)))) + (if jka-compr-use-shell + (let ((err-file (jka-compr-make-temp-name)) + (coding-system-for-read (or coding-system-for-read 'undecided)) + (coding-system-for-write 'no-conversion)) + (unwind-protect + (or (memq + (call-process jka-compr-shell infile + (if (stringp output) nil output) + nil + "-c" + (format "%s %s 2> %s %s" + prog + (mapconcat 'identity args " ") + err-file + (if (stringp output) + (concat "> " output) + ""))) + jka-compr-acceptable-retval-list) + (jka-compr-error prog args infile message err-file)) + (jka-compr-delete-temp-file err-file))) + (or (eq 0 + (apply 'call-process + prog infile (if (stringp output) temp output) + nil args)) + (jka-compr-error prog args infile message)) + (and (stringp output) + (with-current-buffer temp + (write-region (point-min) (point-max) output) + (erase-buffer)))))) ;; Support for temp files. Much of this was inspired if not lifted