Directory recursive walking

dog2002 742617000027 at aaathats3as.com
Thu Jan 14 16:30:40 UTC 2021


On Thursday, 14 January 2021 at 16:18:28 UTC, drug wrote:
> On 1/14/21 7:06 PM, dog2002 wrote:
>> On Thursday, 14 January 2021 at 16:01:43 UTC, drug wrote:
>>> [...]
>> 
>> Yes. I forgot to add it in the original post.
>
> Does using `ref` changed anything?
> Try following:
> ```
> import std;
>
> void DirIteration(ref DirEntry dir) {
>     try {
>         foreach(ref entry; dirEntries(dir, SpanMode.shallow, 
> false)) { //SpanMode.shallow allows skip directories if any 
> error happens
>             if (entry.isFile && !entry.isSymlink)
>                 writeln(entry); //Or something instead of this
>             if (entry.isDir)
>                 DirIteration(entry);
>         }
>     }
>     catch (Throwable) {}
> }
>
> void main()
> {
>     auto de = DirEntry(".");
>     DirIteration(de);
> }
> ```

No, it doesn't. Seems like memory can't clear.


More information about the Digitalmars-d-learn mailing list