[REBOL] Re: make-pool
From: jelinem1:nationwide at: 30-Apr-2001 12:35
Or, for those who want to separate the sub-directories from the regular
files in the output order:
(just replace this function)
recursive: func [dir [file!] /local ext dir-list] [
dir-list: copy []
foreach file read dir [
either not dir? dir/:file [
either found? filter [
if not none? ext: find/last file "." [
if parse next ext extension [append files
dir/:file]
]
][ append files dir/:file ]
][ append dir-list dir/:file ]
]
foreach this-dir dir-list [recursive this-dir]
]
- Michael Jelinek
Fantam <[Fantam--MailAndNews--com]>@rebol.com on 04/30/2001 09:45:51 AM
From: Fantam <[Fantam--MailAndNews--com]>@rebol.com on 04/30/2001 09:45 AM
Please respond to [rebol-list--rebol--com]
Sent by: [rebol-bounce--rebol--com]
To: [rebol-list--rebol--com]
cc:
Subject: [REBOL] make-pool
Hello all,
The following is one of my favorite swiss-knife function, so I
thought I'd share it on this list. It is used to build blocks of
files given a directory, with or without filter.
Here it goes:
REBOL [
Title: "mezzanine function"
Description: "Find files under a given directory"
Date: 18/3/2001
Author: "fantam"
email: [fantam--mailandnews--com]
usage: {
make-pool %/d/docs/
or, with filter:
make-pool/filter %"/d/web sites/rebol/" "htm gif jpg"
}
]
make-pool: func [root-folder [file!]
/filter extension [string!]
/verbose "prints message"
/local files
] [
files: copy []
if found? filter [
extension: parse extension none
if not (length? extension) = 1 [
extension: next extension
while [not tail? extension] [insert extension
to-word "|" extension: next next extension]
extension: head extension
]
]
recursive: func [dir [file!] /local ext] [
foreach file read dir [
either not dir? dir/:file [
either found? filter [
if not none? ext: find/last
file "." [
if parse next ext
extension [append files dir/:file]
]
]
[
append files dir/:file
]
]
[recursive dir/:file]
]
]
either dir? root-folder
[
recursive dirize root-folder
]
[
print [mold root-folder "no valid folder"]
]
if verbose [print reduce [length? files "files in pool."]]
files
]