Function: tramp-crypt-do-encrypt-or-decrypt-file

tramp-crypt-do-encrypt-or-decrypt-file is a byte-compiled function defined in tramp-crypt.el.gz.

Signature

(tramp-crypt-do-encrypt-or-decrypt-file OP ROOT INFILE OUTFILE)

Documentation

Encrypt / decrypt file INFILE to OUTFILE according to encrypted directory ROOT.

Both files must be local files. OP must be encrypt or decrypt. If OP ist decrypt, the basename of INFILE must be an encrypted file name. Raise an error if this fails.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-crypt.el.gz
(defun tramp-crypt-do-encrypt-or-decrypt-file (op root infile outfile)
  "Encrypt / decrypt file INFILE to OUTFILE according to encrypted directory ROOT.
Both files must be local files.  OP must be `encrypt' or `decrypt'.
If OP ist `decrypt', the basename of INFILE must be an encrypted file name.
Raise an error if this fails."
  (when-let ((tramp-crypt-enabled t)
	     (dir (tramp-crypt-file-name-p root))
	     (crypt-vec (tramp-crypt-dissect-file-name dir)))
    (let ((coding-system-for-read
	   (if (eq op 'decrypt) 'binary coding-system-for-read))
	  (coding-system-for-write
	   (if (eq op 'encrypt) 'binary coding-system-for-write)))
      (unless (tramp-crypt-send-command
	       crypt-vec "cat" (and (eq op 'encrypt) "--reverse")
	       (file-name-directory infile)
	       (concat "/" (file-name-nondirectory infile)))
	(tramp-error
	 crypt-vec 'file-error "%s of file %s failed."
	 (if (eq op 'encrypt) "Encrypting" "Decrypting") infile))
      (with-current-buffer (tramp-get-connection-buffer crypt-vec)
	(write-region nil nil outfile)))))