walking a directory tree

Started by tom, December 08, 2007, 10:09:07 AM

Previous topic - Next topic

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:



; 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

#1
Why not make the directory function call a bit smarter:


directory dir {^[^.]})

There's a few examples in http://newlisp.org/introduction-to-newlisp.html#recursiveversion">//http://newlisp.org/introduction-to-newlisp.html#recursiveversion


QuoteI may well be too stupid for newlisp.


Enough modesty! If you can use Linux you're much smarter than I am... :)

tom

#2
Quote from: "cormullion"
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!