[REBOL] Re: Recursive-Read question
From: bry:itnisk at: 5-Nov-2002 18:04
>The problem there is that if I want to get something hierarchical out
of
>it, I can't.
>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>"]
> ]
Okay thinking about the problem I thought it might be easier to do with
a while[not tail? Files] like the following:
Address: ftp://some-ftp.site
Files: read Address
while [not tail? Files] [File: First Files address: either directory?
File[rejoin[address
/
File]][ rejoin[address File]] read address Files: Next Files]
Figure I'd add in the Xml generation step later, once I know I am
recursively parsing the file tree.
this, like anything one is unsure of, raises an error.
** Access Error: Invalid port spec: ENIdea.xml ENIdea_files/ T1/
bryanstest.xml bryanstest2.x
ml copyright.htm date.jsp date2.jsp mods.xml result.html result.xml
result2.html result2.xml
velkommen.htm / T2/ / T2/ / T2/ / T2/
** Where: halt-view
** Near: read address