| 1 |
// assuming we're in g_cwd, all entries of type 'type' matching source/pattern |
| 2 |
// are returned w/o final \n |
| 3 |
|
| 4 |
list findAll(string type, string source, string pattern) |
| 5 |
{ |
| 6 |
string cmd; |
| 7 |
list entries; |
| 8 |
list ret; |
| 9 |
int idx; |
| 10 |
|
| 11 |
chdir(source); |
| 12 |
|
| 13 |
cmd = "find ./ -mindepth 1 -maxdepth 1 -type " + type; |
| 14 |
|
| 15 |
if (pattern != "") |
| 16 |
pattern = "-name '" + pattern + "'"; |
| 17 |
|
| 18 |
entries = backtick(cmd + " " + pattern + " -printf \"%f\\n\""); |
| 19 |
|
| 20 |
idx = listlen(entries); |
| 21 |
|
| 22 |
if (idx > 0 && strlen(entries[0]) > 0) |
| 23 |
{ |
| 24 |
for (idx = listlen(entries); idx--; ) |
| 25 |
ret += (list)cutEoln(entries[idx]); |
| 26 |
} |
| 27 |
|
| 28 |
chdir(g_cwd); |
| 29 |
|
| 30 |
return ret; |
| 31 |
} |