find-file: func [
{Based on an idea by Sunanda. Find a file in one of the specified
dirs and return it, fully qualified.}
dirs [block!]
file [file!]
/local normalize-dir normalize-file path
][
normalize-dir: func [
"Remove any leading slashes, ensure a trailing slash"
dir
][
while [#"/" = first dir] [remove dir]
to-file dirize dir
]
normalize-file: func [
"Remove any leading slashes"
file
][
while [#"/" = first file] [remove file]
to-file file
]
foreach dir dirs [
path: join what-dir normalize-dir form dir
if exists? result: join path normalize-file file [return result]
]
]