dirEntries removes entire branches of empty directories

Vladimir Panteleev thecybershadow.lists at gmail.com
Wed Nov 9 19:30:01 UTC 2022


On Wednesday, 9 November 2022 at 19:05:58 UTC, Ali Çehreli wrote:
> Running the program shows no output; 'a' is not visited as a 
> directory entry.

That's not what happens for me:

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

void ls()
{
     foreach (e; dirEntries(absolutePath("./deleteme"), 
SpanMode.breadth)) {
         writeln(e.name);
     }	
}

void main()
{
	"./deleteme".rmdirRecurse.collectException;
	"./deleteme".mkdir();

	writeln("empty");
	ls();

	writeln("only a directory");
	mkdir("./deleteme/a");
	ls();

	writeln("directory and file");
	std.file.write("./deleteme/a/x", "");
	ls();
}
```

Locally and on run.dlang.io I get:

```
empty
only a directory
/sandbox/./deleteme/a
directory and file
/sandbox/./deleteme/a
/sandbox/./deleteme/a/x
```



More information about the Digitalmars-d-learn mailing list