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
Message #318 received at 10489 <at> debbugs.gnu.org (full text, mbox):
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:
> (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))
Not needed anymore, you have called the handler already.
> (equal (file-attributes (file-truename file1))
> (file-attributes (file-truename file2)))))))
Here we have the discussion about the inode numbers. But this is an edge
case; let's go this way. Eli will fix it for Windows :-)
> (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))))))
Looks OK on the first glance.
> BTW I have added the COPY-CONTENTS arg to your handler in
> `copy-directory'.
Thanks.
Best regards, Michael.
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.