A nickel for today - file tree -

Featuring the Dragonfly web framework
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

A nickel for today - file tree -

Post by newdep »

copy failure ;-) ** repost **

#!/usr/bin/newlisp

;;; displays all directory's you have access to ;;;
;;; does not follow symlinks -- usage tree.lsp "/"
[text]
(define (dir-tree D)
(dolist (T (sort (filter directory? (map (fn(x) (append D x "/")) (difference (directory D) '( "." ".."))))))
(if (and (not (= 0x2000 (& (file-info (chop T) 1) 0x2000))) (directory T)) (and (println T) (dir-tree T))) ))
(dir-tree (main-args 2))
[/text]

;;; displays all directory's and files you have access to ;;;
;;; does not follow symlinks -- is 5 seconds slower then unix FIND + files
[text]
(define (file-tree D)
(dolist (T (sort (filter directory? (map (fn(x) (append D x "/")) (difference (directory D) '( "." ".."))))))
(if (and (not (= 0x2000 (& (file-info (chop T) 1) 0x2000))) (directory T)) (and (dolist (L (sort (directory T))) (println (append T L))) (file-tree T))) ))
(file-tree (main-args 2))
[/text]

;;; displays all directory's and files you have access to ;;;
;;; does not follow symlinks -- is 1 second slower then unix FIND + files
[text]
(define (file-tree D)
(dolist (T (sort (filter (fn(y) (not (= 0x2000 (& (file-info (chop y) 1) 0x2000)))) (filter directory? (map (fn(x) (append D x "/")) (difference (directory D) '( "." "..")))))))
(and (directory T) (println T) (file-tree T))))
[/text]



(define (file-tree D)
(dolist (L (setq T (sort (filter (fn(y) (not (= 0x2000 (& (file-info (chop y) 1) 0x2000)))) (filter directory? (map (fn(x) (append D x "/")) (difference (directory D) '( "." ".."))))))))
(and (setq X (directory L)) (dolist (x X) (println L x)) (file-tree L))))


(file-tree (string (main-args 2)))
(exit)
-- (define? (Cornflakes))

Locked