"Like `make-directory' for Tramp files."
(setq dir (expand-file-name dir))
(with-parsed-tramp-file-name dir nil
+ (when (and (null parents) (file-exists-p dir))
+ (tramp-error v 'file-already-exists "Directory already exists %s" dir))
(when parents
(let ((par (expand-file-name ".." dir)))
(unless (file-directory-p par)
"Like `make-directory' for Tramp files."
(setq dir (directory-file-name (expand-file-name dir)))
(with-parsed-tramp-file-name dir nil
+ (when (and (null parents) (file-exists-p dir))
+ (tramp-error v 'file-already-exists "Directory already exists %s" dir))
(tramp-flush-directory-properties v localname)
(save-match-data
(let ((ldir (file-name-directory dir)))
"Like `make-directory' for Tramp files."
(setq dir (expand-file-name dir))
(with-parsed-tramp-file-name dir nil
+ (when (and (null parents) (file-exists-p dir))
+ (tramp-error v 'file-already-exists "Directory already exists %s" dir))
;; When PARENTS is non-nil, DIR could be a chain of non-existent
;; directories a/b/c/... Instead of checking, we simply flush the
;; whole cache.
(unless (file-name-absolute-p dir)
(setq dir (expand-file-name dir default-directory)))
(with-parsed-tramp-file-name dir nil
+ (when (and (null parents) (file-exists-p dir))
+ (tramp-error v 'file-already-exists "Directory already exists %s" dir))
(let* ((ldir (file-name-directory dir)))
;; Make missing directory parts.
(when (and parents
"Like `make-directory' for Tramp files."
(setq dir (expand-file-name dir))
(with-parsed-tramp-file-name dir nil
+ (when (and (null parents) (file-exists-p dir))
+ (tramp-error v 'file-already-exists "Directory already exists %s" dir))
;; When PARENTS is non-nil, DIR could be a chain of non-existent
;; directories a/b/c/... Instead of checking, we simply flush the
;; whole cache.
(defun tramp-handle-copy-directory
(directory newname &optional keep-date parents copy-contents)
"Like `copy-directory' for Tramp files."
- ;; `directory-files' creates `newname' before running this check.
- ;; So we do it ourselves.
+ ;; `copy-directory' creates NEWNAME before running this check. So
+ ;; we do it ourselves.
(unless (file-exists-p directory)
(tramp-error
(tramp-dissect-file-name directory) tramp-file-missing
;; Forwhatever reasons, the following tests let Emacs crash for
;; Emacs 24 and Emacs 25, occasionally. No idea what's up.
- (when (or (tramp--test-emacs26-p) (tramp--test-emacs27-p))
+ (when (tramp--test-emacs26-p)
(should
(string-equal (substitute-in-file-name "/method:host://~foo") "/~foo"))
(should
(unwind-protect
(progn
(make-directory tmp-name1)
+ (should-error
+ (make-directory tmp-name1)
+ :type 'file-already-exists)
(should (file-directory-p tmp-name1))
(should (file-accessible-directory-p tmp-name1))
- (should-error (make-directory tmp-name2) :type 'file-error)
+ (should-error
+ (make-directory tmp-name2)
+ :type 'file-error)
(make-directory tmp-name2 'parents)
(should (file-directory-p tmp-name2))
(should (file-accessible-directory-p tmp-name2))
(should (file-directory-p tmp-name2))
(write-region "foo" nil (expand-file-name "bla" tmp-name2))
(should (file-exists-p (expand-file-name "bla" tmp-name2)))
- (should-error (delete-directory tmp-name1) :type 'file-error)
+ (should-error
+ (delete-directory tmp-name1)
+ :type 'file-error)
(delete-directory tmp-name1 'recursive)
(should-not (file-directory-p tmp-name1)))))
(when (tramp--test-emacs26-p)
(should-error
(copy-directory tmp-name1 tmp-name2)
- :type 'file-error))
+ :type 'file-already-exists))
(copy-directory tmp-name1 (file-name-as-directory tmp-name2))
(should (file-directory-p tmp-name3))
(should (file-exists-p tmp-name6)))
:type 'file-error)
(make-symbolic-link tmp-name1 tmp-name2)
(should (file-symlink-p tmp-name2))
- (should-error (file-truename tmp-name1) :type 'file-error))))
+ (should-error
+ (file-truename tmp-name1)
+ :type 'file-error))))
;; Cleanup.
(ignore-errors
(while (accept-process-output proc nil nil 0)))
(should-not (process-live-p proc))
;; An interrupted process cannot be interrupted, again.
- (should-error (interrupt-process proc) :type 'error))
+ (should-error
+ (interrupt-process proc)
+ :type 'error))
;; Cleanup.
(ignore-errors (delete-process proc)))))