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 #213 received at submit <at> debbugs.gnu.org (full text, mbox):
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:
> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>> You also need to check whether the target is a subdirectory of the
>> source.
> Indeed yes, is there already a function to check this?
> If not what about something like this:
BTW this work also for equality between two directories.
(both GNU/Linux and Windows)
#+BEGIN_SRC lisp
(defun file-subdir-of-p (file1 file2)
"Check if FILE1 is a subdirectory of FILE2."
(when (and (not (or (file-remote-p file1)
(file-remote-p file2)))
(not (string= file1 "/"))
(file-directory-p file1)
(file-directory-p file2))
(or (string= file2 "/")
(loop with f1 = (expand-file-name file1)
with f2 = (expand-file-name file2)
with ls1 = (split-string f1 "/" t)
with ls2 = (split-string f2 "/" t)
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
;; Use here `file-equal-p' when ready to work.
(string= (file-truename (directory-file-name root))
(file-truename(directory-file-name f2)))))))
#+END_SRC
--
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.