www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.file.listdir fix

I rewrote this function and added:

1) overloaded to accept a callback delegate instead of constructing a
possibly huge array.
2) implemented linux version.

This attached code is donated to the origional author of file.d and can have
the same license.

--
Christopher E. Miller


begin 666 listdir.txt
M=F5R<VEO;BA7:6XS,BD-"GL-" EV;VED(&QI<W1D:7(H8VAA<EM=('!A=&AN
M86UE+"!B;V]L(&1E;&5G871E*&-H87);72!F:6QE;F%M92D 8V%L;&)A8VLI
M#0H)>PT*"0E(04Y$3$4 :#L-" D)#0H)"7!A=&AN86UE(#T <W1D+G!A=& N
M:F]I;BAP871H;F%M92P (BHB*3L-" D):68H=7-E5V9U;F-S*0T*"0E[#0H)
M"0E724XS,E]&24Y$7T1!5$%7(&9D871A.PT*"0D)#0H)"0EH(#T 1FEN9$9I
M<G-T1FEL95<H<W1D+G5T9BYT;U541C$V>BAP871H;F%M92DL("9F9&%T82D[
M#0H)"0EI9BA)3E9!3$E$7TA!3D1,15]604Q512 A/2!H*0T*"0D)>PT*"0D)
M"61O#0H)"0D)>PT*"0D)"0DO+R!3:VEP("(N(B!A;F0 (BXN( T*"0D)"0EI
M9B A<W1D+G-T<FEN9RYW8W-C;7 H9F1A=&$N8T9I;&5.86UE+" B+B(I('Q\
M#0H)"0D)"0DA<W1D+G-T<FEN9RYW8W-C;7 H9F1A=&$N8T9I;&5.86UE+" B
M+BXB*2D-" D)"0D)"0EC;VYT:6YU93L-" D)"0D)#0H)"0D)"6EN="!L96X 
M/2!S=&0N<W1R:6YG+G=C<VQE;BAF9&%T82YC1FEL94YA;64I.PT*"0D)"0DO
M+R!!<W-U;65S('1O551&." I(')E='5R;G, 82!N97< 8G5F9F5R+ T*"0D)
M"0EI9B A8V%L;&)A8VLH<W1D+G5T9BYT;U541C H9F1A=&$N8T9I;&5.86UE
M6S  +BX ;&5N72DI*0T*"0D)"0D)8G)E86L[#0H)"0D)?0T*"0D)"7=H:6QE
M*$9I;F1.97AT1FEL95<H:"P )F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