[svn:mod_parrot] r341 - mod_parrot/trunk/lib
[email protected] Thu, 29 May 2008 08:16:37 -0700 (PDT)
| Newsgroups | perl.cvs.mod_parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: jhorwitz
Date: Thu May 29 08:16:36 2008
New Revision: 341
Modified:
mod_parrot/trunk/lib/mod_parrot.pir
Log:
add find_file_in_path sub to search for files in paths (e.g. PERL6LIB)
Modified: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/trunk/lib/mod_parrot.pir (original)
+++ mod_parrot/trunk/lib/mod_parrot.pir Thu May 29 08:16:36 2008
@@ -107,11 +107,32 @@
count = elements pathlist
$I0 = count
-PATH_LOOP:
+ path_loop:
dec $I0
path = pathlist[$I0]
unshift include_paths, path
- if $I0 > 0 goto PATH_LOOP
+ if $I0 > 0 goto path_loop
.return(count)
.end
+
+.sub find_file_in_path
+ .param string search_path
+ .param string filename
+ .local string path
+ .local pmc iter
+
+ $P0 = split ':', search_path
+ iter = new 'Iterator', $P0
+ iter_start:
+ null path
+ unless iter goto return_path
+ $S0 = shift iter
+ path = concat $S0, '/'
+ path .= filename
+ $I0 = stat path, 0
+ unless $I0 goto iter_start
+
+ return_path:
+ .return(path)
+.end