path matching problem
Charles Hixson
charleshixsn at earthlink.net
Tue Nov 27 11:40:23 PST 2012
Is there a better way to do this? (I want to find files that match any
of some extensions and don't match any of several other strings, or are
not in some directories.):
import std.file;
...
string exts = "*.{txt,utf8,utf-8,TXT,UTF8,UTF-8}";
string[] exclude = ["/template/", "biblio.txt", "categories.txt",
"subjects.txt", "/toCDROM/"]
int limit = 1
// Iterate a directory in depth
foreach (string name; dirEntries(sDir, exts, SpanMode.depth))
{ bool excl = false;
foreach (string part; exclude)
{ if (part in name)
{ excl = true;
break;
}
}
if (excl) break;
etc.
More information about the Digitalmars-d-learn
mailing list