Function: tramp-adb-handle-write-region

tramp-adb-handle-write-region is a byte-compiled function defined in tramp-adb.el.gz.

Signature

(tramp-adb-handle-write-region START END FILENAME &optional APPEND VISIT LOCKNAME MUSTBENEW)

Documentation

Like write-region for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-adb.el.gz
(defun tramp-adb-handle-write-region
  (start end filename &optional append visit lockname mustbenew)
  "Like `write-region' for Tramp files."
  (tramp-skeleton-write-region start end filename append visit lockname mustbenew
    ;; If `start' is the empty string, it is likely that a temporary
    ;; file is created.  Do it directly.
    (if (and (stringp start) (string-empty-p start))
	(tramp-adb-send-command-and-check
	 v (format "echo -n \"\" >%s" (tramp-shell-quote-argument localname)))

      (let ((tmpfile (tramp-compat-make-temp-file filename)))
	(when (and append (file-exists-p filename))
	  (copy-file filename tmpfile 'ok)
	  (set-file-modes tmpfile (logior (or (file-modes tmpfile) 0) #o0600)))
	(let (create-lockfiles)
          (write-region start end tmpfile append 'no-message))
	;; Now, `last-coding-system-used' has the right value.  Remember it.
	(setq coding-system-used last-coding-system-used)
	(with-tramp-progress-reporter
	    v 3 (format-message
		 "Moving tmp file `%s' to `%s'" tmpfile filename)
	  (unwind-protect
	      (unless (tramp-adb-execute-adb-command
		       v "push" tmpfile (file-name-unquote localname))
		(tramp-error v 'file-error "Cannot write: `%s'" filename))
	    (delete-file tmpfile)))))))