We could use a hasExt function in std.path
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Apr 1 14:15:36 PDT 2011
On 4/1/11, Andrej Mitrovic <none at none.none> wrote:
> I often have to search for files that have a certain extension. Having to
> expand the code to the following becomes ugly real fast:
>
> foreach (string name; dirEntries(curdir, SpanMode.shallow))
> {
> if (name.isFile && name.hasExt.tolower == "ini" ||
> name.hasExt.tolower == "conf"))
> {
> // do something
> }
> }
>
Oops, that showcase was supposed to use `getExt`.
More information about the Digitalmars-d-learn
mailing list