GNU bug report logs -
#10489
24.0.92; dired-do-copy may create infinite directory hierarchy
Previous Next
Reported by: michael_heerdegen <at> web.de
Date: Thu, 12 Jan 2012 19:36:01 UTC
Severity: important
Tags: patch
Merged with 11130
Found in version 24.0.92
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Michael Albinus <michael.albinus <at> gmx.de> writes:
> Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:
>
>> However, Michael I would like to have more precisions for the call of
>> tramp handlers.
>
> What exactly? It's always the same scenario: Check for the handler, and
> if there is any, call it. You can reuse the code snippet from all
> functions which do so.
>
> If you are uncertain, show your code; I'll comment.
So here the functions, please have a look:
(defun files-equal-p (file1 file2)
"Return non-nil if FILE1 and FILE2 name the same file."
(let ((handler (or (find-file-name-handler file1 'files-equal-p)
(find-file-name-handler file2 'files-equal-p))))
(if handler
(funcall handler 'files-equal-p file1 file2)
(and (equal (file-remote-p file1) (file-remote-p file2))
(equal (file-attributes (file-truename file1))
(file-attributes (file-truename file2)))))))
(defun file-subdir-of-p (dir1 dir2)
"Return non-nil if DIR1 is a subdirectory of DIR2.
Note that a directory is treated by this function as a subdirectory of itself.
This function only works when its two arguments already exist,
when they don't, it returns nil."
(let ((handler (or (find-file-name-handler dir1 'file-subdir-of-p)
(find-file-name-handler dir2 'file-subdir-of-p))))
(if handler
(funcalll handler 'file-subdir-of-p dir1 dir2)
(when (and (file-directory-p dir1)
(file-directory-p dir2))
(loop with f1 = (file-truename dir1)
with f2 = (file-truename dir2)
with ls1 = (or (split-string f1 "/" t) (list "/"))
with ls2 = (or (split-string f2 "/" t) (list "/"))
for p = (string-match "^/" f1)
for i in ls1
for j in ls2
when (string= i j)
concat (if p (concat "/" i) (concat i "/"))
into root
finally return
(files-equal-p (file-truename root) f2))))))
BTW I have added the COPY-CONTENTS arg to your handler in
`copy-directory'.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
This bug report was last modified 13 years and 58 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.