Function: tramp-smb-handle-delete-file

tramp-smb-handle-delete-file is a byte-compiled function defined in tramp-smb.el.gz.

Signature

(tramp-smb-handle-delete-file FILENAME &optional TRASH)

Documentation

Like delete-file for Tramp files.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-smb.el.gz
(defun tramp-smb-handle-delete-file (filename &optional trash)
  "Like `delete-file' for Tramp files."
  (setq filename (expand-file-name filename))
  (when (file-exists-p filename)
    (with-parsed-tramp-file-name filename nil
      ;; We must also flush the cache of the directory, because
      ;; `file-attributes' reads the values from there.
      (tramp-flush-file-properties v localname)
      (if (and delete-by-moving-to-trash trash)
	  (move-file-to-trash filename)
	(unless (tramp-smb-send-command
		 v (format
		    "%s \"%s\""
		    (if (tramp-smb-get-cifs-capabilities v) "posix_unlink" "rm")
		    (tramp-smb-get-localname v)))
	  ;; Error.
	  (with-current-buffer (tramp-get-connection-buffer v)
	    (goto-char (point-min))
	    (search-forward-regexp tramp-smb-errors nil t)
	    (tramp-error v 'file-error "%s `%s'" (match-string 0) filename)))))))