walking a directory tree

Q&A's, tips, howto's
Locked
tom
Posts: 168
Joined: Wed Jul 14, 2004 10:32 pm

walking a directory tree

Post by tom »

Hi guys,

I may well be too stupid for newlisp. I'm a glutton for punishment, however, so I'll press on :-)

here is the "show-tree" function from the Code Patterns document:

Code: Select all

; walks a disk directory and prints all path-file names
	;
	(define (show-tree dir)
	    (if (directory dir)
	        (dolist (nde (directory dir))
	           (if (and (directory? (append dir "/" nde)) 
	                    (!= nde ".") (!= nde ".."))
	                 (show-tree (append dir "/" nde))
	                 (println (append dir "/" nde))))))
I've asked about it before. I just can't figure it out. I don't want any output returned that include current or parent directories ( "." and "..").

Once I (you) solve this little dilemma I will be well on my way to world domination.
[/code]

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Why not make the directory function call a bit smarter:

Code: Select all

directory dir {^[^.]})
There's a few examples in http://newlisp.org/introduction-to-newl ... iveversion
I may well be too stupid for newlisp.
Enough modesty! If you can use Linux you're much smarter than I am... :)

tom
Posts: 168
Joined: Wed Jul 14, 2004 10:32 pm

Post by tom »

cormullion wrote: Enough modesty! If you can use Linux you're much smarter than I am... :)
I doubt it, but thanks. Your solution is easy, and it works fine. Look out world!

Locked