Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: recursive directory copying...

From: antonr:iinet:au at: 13-May-2003 14:13

I wrote a tree function which works well so far. You can insert user-code to be executed as each directory is visited. eg: tree/quiet/code %start-dir/ [ print rejoin dir-path ; current relative directory foreach file files [print dir/:file] ; all the files ] Since you can modify the user-code block, you could easily change its behaviour for your purpose. Here's the necessary init code for a full example: rebsite: select load-thru http://www.reboltech.com/index.r [folder "Anton"] clear find rebsite %index.r do load-thru rebsite/library/include.r include [rebsite/library/tree.r [tree] rebsite/library/dir-utils.r [push pop]] tree %./ ; <- now use it... The downside to my tree is that it is quite big compared to recursive functions because it is stack-based, it needs 'push and 'pop from dir-utils, and 'include needs to be defined first. You could rip out the three functions you need from tree.r and dir-utils.r though. The upside is it works and seems to me to be quite stable. It catches errors and prints them out, but that doesn't stop the function. Here's a direct link: http://www.lexicon.net/anton/rebol/library/tree.r Anton Rolls.