iterate over a directory, dealing with permission errors

Daniel Pflager daniel.pflager at gmail.com
Sat Jan 22 02:09:39 UTC 2022


https://forum.dlang.org/post/pldneecaysxueshzwopx@forum.dlang.org

On Sunday, 23 May 2021 at 15:19:34 UTC, xray wrote:
> On Sunday, 23 May 2021 at 15:13:31 UTC, Mike Parker wrote:
>> On Sunday, 23 May 2021 at 15:12:22 UTC, Mike Parker wrote:
>>
>>> Are you calling it with `RangePrimitive.pop` or 
>>> `RangePrimitive.popFront`?
>>
>> I meant, `RangePrimitive.front` or `RangePrimitive.popFront`.
>
> RangePrimitive.popFront
>
> In SpanMode.depth  I still get the FileException and in 
> SpanMode.breadth, the program hangs for ever.

I've got a test environment set up.

DMD32 D Compiler v2.098.0-dirty
Copyright (C) 1999-2021 by The D Language Foundation, All Rights 
Reserved written by Walter Bright

Windows 10 Enterprise (1909) OS Build 18363.2037


Test program (fixit.d):

```
import std.exception;
import std.file;
import std.stdio;

int main(string[] args) {
	// Use glob to search by glob pattern
	foreach (string name; dirEntries(args[1], SpanMode.breadth, 
false).handle!(FileException, RangePrimitive.popFront, (e, r) => 
DirEntry())) {
		writeln(name);
	}
	return 0;
}
```

Using git bash shell GNU bash, version 4.4.23(1)-release 
(x86_64-pc-msys)

```
time ./fixit.exe C:\\
```

Results in ...

```
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
C:\$Recycle.Bin\S-1-5-21-2025429265-1303643608-1417001333-1255143\$RTQTCU0.1-javadoc
.
.
.
```


More information about the Digitalmars-d mailing list