Mercurial > projects > ldc
comparison tango/example/conduits/filescanregex.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 /************************************************************** | |
2 | |
3 Example that use FileScan and Regex as a filter. | |
4 | |
5 Put into public domain by Lars Ivar Igesund | |
6 | |
7 **************************************************************/ | |
8 | |
9 import tango.io.File, | |
10 tango.io.Stdout, | |
11 tango.io.FileScan, | |
12 tango.text.Regex; | |
13 | |
14 void main(char[][] args) { | |
15 uint total; | |
16 | |
17 if (args.length < 2) { | |
18 Stdout("Please pass a directory to search").newline; | |
19 return; | |
20 } | |
21 | |
22 scope scan = new FileScan; | |
23 scope regex = Regex(r"\.(d|obj)$"); | |
24 | |
25 scan(args[1], delegate bool (FilePath fp, bool isDir) { | |
26 ++total; | |
27 return isDir || regex.test(fp.toString); | |
28 }); | |
29 | |
30 | |
31 foreach (file; scan.files) | |
32 Stdout(file).newline; | |
33 | |
34 Stdout.formatln("Found {} matches in {} entries", scan.files.length, total); | |
35 | |
36 Stdout.formatln ("\n{} Errors", scan.errors.length); | |
37 foreach (error; scan.errors) | |
38 Stdout (error).newline; | |
39 } | |
40 |