Function: tramp-sh-handle-dired-compress-file
tramp-sh-handle-dired-compress-file is a byte-compiled function
defined in tramp-sh.el.gz.
Signature
(tramp-sh-handle-dired-compress-file FILE)
Documentation
Like dired-compress-file for Tramp files.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
;; Dired.
(defun tramp-sh-handle-dired-compress-file (file)
"Like `dired-compress-file' for Tramp files."
;; Code stolen mainly from dired-aux.el.
(with-parsed-tramp-file-name file nil
(tramp-flush-file-properties v localname)
(let ((suffixes dired-compress-file-suffixes)
suffix)
;; See if any suffix rule matches this file name.
(while suffixes
(let (case-fold-search)
(if (string-match-p (car (car suffixes)) localname)
(setq suffix (car suffixes) suffixes nil))
(setq suffixes (cdr suffixes))))
(cond ((file-symlink-p file) nil)
((and suffix (nth 2 suffix))
;; We found an uncompression rule.
(with-tramp-progress-reporter
v 0 (format "Uncompressing %s" file)
(when (tramp-send-command-and-check
v (concat (nth 2 suffix) " "
(tramp-shell-quote-argument localname)))
(dired-remove-file file)
(string-match (car suffix) file)
(concat (substring file 0 (match-beginning 0))))))
(t
;; We don't recognize the file as compressed, so compress it.
;; Try gzip.
(with-tramp-progress-reporter v 0 (format "Compressing %s" file)
(when (tramp-send-command-and-check
v (concat "gzip -f "
(tramp-shell-quote-argument localname)))
(dired-remove-file file)
(cond ((file-exists-p (concat file ".gz"))
(concat file ".gz"))
((file-exists-p (concat file ".z"))
(concat file ".z"))
(t nil)))))))))