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

[REBOL] Recursive-Read question

From: bry::itnisk::com at: 5-Nov-2002 13:49

Hi, I have a question about the Recursive-Read function, which is provided in http://www.reboltech.com/library/html/Recursive Read.html Now of course what it does is not to Recursively Read a directory but rather read a file or Url into a block and then recursively read that block. The problem there is that if I want to get something hierarchical out of it, I can't. As an example of what I mean I have the following: xml-dec: rejoin["<?xml version='1.0' encoding='ISO-8859-1'?><files>"] write %dir.xml xml-dec sep: "/" ReadDir-ToXml: function [ "Based on Andrew Martin's Recursive-Read." Directory [file! url!]] [Files Subdirectory] [ Files: read Directory if block? Files [ foreach File Files [ if directory? File [ path: replace/all Directory/:Subdirectory/:File "none/" "" path: replace/all path Subdirectory "" write/append %dir.xml rejoin["<folder name='" File"' path='" path "' modified='" modified? File "' size='" size? File "'>"] Subdirectory: File foreach File read Directory/:Subdirectory [ name: to-string File either find name sep[ append Files Subdirectory/:File ][ write/append %dir.xml reduce[ "<file name='" File "' path='" Directory/:Subdirectory/:File "' modified='" modified? File "' size='" size? File "'/>"] ] ] write/append %dir.xml "</folder>" ] ] ] write/append %dir.xml rejoin["</files>"] ] So anyway I was hoping to get some help on this, things I'd like help with are 1. since I'm still in the beginner phase with Rebol and just taking scripts like this for reuse, what are some most evident things I could do to include the coding of ReadDir-ToXml now that I muddied it all up? 2. Is there a simple way to make it hierarchical? If not it doesn't matter as I could write an xslt that reprocessed it no problem.