---
directory-files-deep
(defun directory-files-no-dotdotdot (directory &optional full match nosort)
"Author: Davin Pearson <http://davin.50webs.com>"
(let* ((case-fold-search t)
(list (directory-files directory full match nosort))
(ptr list))
(while ptr
(if (string= (car ptr) "")
(setcar ptr nil))
(if (string-match "/\\.$" (car ptr))
(setcar ptr "."))
(if (string-match "/\\..$" (car ptr))
(setcar ptr ".."))
(setq ptr (cdr ptr)))
(setq list (delete "." list))
(setq list (delete ".." list))
(setq list (delq nil list))
list))
(defun directory-files-subdirs (directory &optional full match nosort)
"Author: Davin Pearson <http://davin.50webs.com>
NOTE: no .. and ."
(let* ((case-fold-search t)
(list (directory-files-no-dotdotdot directory full match nosort))
(ptr list)
(dir nil))
(setq directory (expand-file-name directory))
(if (string-match "^\\(.*\\)/$" directory)
(setq directory (substring directory 0 (match-end 1))))
(while ptr
(when (and full (string= (concat directory "/") (car ptr)))
(setf (car ptr) nil)
)
(when (and (not full) (string= (car ptr) ""))
(setf (car ptr) nil)
)
(when (car ptr)
(setq dir (if full (car ptr) (concat directory "/" (car ptr))))
(when (not (file-directory-p dir)) (setf (car ptr) nil)))
(setq ptr (cdr ptr)))
(setq list (delq nil list))
list))
(defalias 'directory-files-nondirs 'directory-files-no-subdirs)
(defun directory-files-no-subdirs (directory &optional full match nosort)
"Author: Davin Pearson <http://davin.50webs.com>
NOTE: no .. and ."
(let* ((case-fold-search t)
(list (directory-files-no-dotdotdot directory full match nosort))
(ptr list))
(if (string-match "\\(.*\\)/$" directory)
(setq directory (substring directory (match-beginning 1) (match-end 1))))
(while ptr
(if (file-directory-p (if full (car ptr) (concat directory "/" (car ptr))))
(setcar ptr nil))
(setq ptr (cdr ptr)))
(setq list (delq nil list))
list)
)
(d-quote defun directory-files-deep-inner--string-lessp (string-1 string-2)
"Author: Davin Pearson <http://davin.50webs.com>"
(let ((dir-1 nil)
(dir-2 nil))
(if (not (boundp 'full))
(error "Variable full not bound"))
(if (not (boundp 'directory))
(error "Variable directory not bound"))
(if (file-directory-p (if full string-1 (concat directory "/" string-1)))
(progn
(setq dir-1 string-1)
(setq string-1 ""))
(progn
(setq dir-1 (file-name-directory string-1))
(setq string-1 (file-name-nondirectory string-1))))
(if (not dir-1) (setq dir-1 ""))
(if (not string-1) (setq string-1 ""))
-------------------------------------------------------------------
(if (file-directory-p (if full string-2 (concat directory "/" string-2)))
(progn
(setq dir-2 string-2)
(setq string-2 ""))
(progn
(setq dir-2 (file-name-directory string-2))
(setq string-2 (file-name-nondirectory string-2))))
(if (not dir-2) (setq dir-2 ""))
(if (not string-2) (setq string-2 ""))
-------------------------------------------------------------------
(cond
((string= dir-1 dir-2)
(string-lessp string-1 string-2))
(t
(string-lessp dir-1 dir-2)))
)
)
(defun directory-files-deep-inner (directory &optional full match nosort)
"Author: Davin Pearson <http://davin.50webs.com>
NOTE: no .. and ."
(setq directory (expand-file-name directory))
(if (string-match "\\(.*\\)/$" directory)
(setq directory (substring directory (match-beginning 1) (match-end 1))))
(message "directory-files-deep scanning %s " directory)
(let*
((list-files-that-match (directory-files-no-dotdotdot directory full match nosort))
(list-all-subdirs (directory-files-subdirs directory full nil nosort))
(return-list list-files-that-match)
(ptr nil)
(sub-files-list nil))
(setq ptr list-all-subdirs)
(while ptr
(setq sub-files-list (directory-files-deep-inner (if full (car ptr)
(concat directory "/" (car ptr)))
full match nosort))
(if (not full)
(setq sub-files-list (mapcar (function (lambda (filename)
(concat (car ptr) "/" filename)
)) sub-files-list)))
(setq return-list (append sub-files-list return-list))
(setq ptr (cdr ptr)))
(if os-type--mswindows-p
(setq return-list (delete-duplicates return-list :test 'string=-ignore-case))
(setq return-list (delete-duplicates return-list :test 'string=)))
(if (not nosort)
(setq return-list (sort* return-list
'string<
:key 'downcase)))
return-list))
(defun directory-files-deep (directory &optional full match nosort)
"Author: Davin Pearson <http://davin.50webs.com> NOTE: no .. and ."
(let ((case-fold-search t)
(result (directory-files-deep-inner directory full match nosort)))
result))
(provide 'directory-files-deep)