File tree 1 file changed +13
-12
lines changed
1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -5192,21 +5192,22 @@ auto dirEntries(bool useDIP1000 = dip1000Enabled)
5192
5192
chdir(root);
5193
5193
scope (exit) chdir (origWD);
5194
5194
5195
- // When issue #9584 is triggered,
5196
- // one of the `isDir` calls fails with "No such file or directory".
5197
- foreach (string entry; " ." .dirEntries(SpanMode.shallow))
5195
+ /*
5196
+ This wouldn't work if `entry` were a `string` – for obvious reasons:
5197
+ One cannot (reliably) iterate nested directory trees using relative path strings
5198
+ while changing directories in between.
5199
+
5200
+ The expected error would be something along the lines of:
5201
+ > Failed to stat file `./3/5': No such file or directory
5202
+
5203
+ See <https://github.com/dlang/phobos/issues/9584> for further details.
5204
+ */
5205
+ foreach (DirEntry entry; " ." .dirEntries(SpanMode.shallow))
5198
5206
{
5199
5207
if (entry.isDir)
5200
- {
5201
- foreach (string subEntry; entry.dirEntries(SpanMode.shallow))
5202
- {
5208
+ foreach (DirEntry subEntry; entry.dirEntries(SpanMode.shallow))
5203
5209
if (subEntry.isDir)
5204
- {
5205
- chdir(subEntry.absolutePath);
5206
- assert (subEntry.absolutePath);
5207
- }
5208
- }
5209
- }
5210
+ chdir(subEntry.absolutePath); // ←
5210
5211
}
5211
5212
}
5212
5213
You can’t perform that action at this time.
0 commit comments