Skip to content

Commit 89f5914

Browse files
authored
Revert "Fix #9584 - Using dirEntries and chdir() can have unwanted results (#10666)" (#10718)
This essentially reverts commit 274109b.
1 parent 0edef23 commit 89f5914

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

std/file.d

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4695,7 +4695,6 @@ private struct DirIteratorImpl
46954695
bool toNext(bool fetch, scope WIN32_FIND_DATAW* findinfo) @trusted
46964696
{
46974697
import core.stdc.wchar_ : wcscmp;
4698-
import std.string : chompPrefix;
46994698

47004699
if (fetch)
47014700
{
@@ -4712,7 +4711,7 @@ private struct DirIteratorImpl
47124711
popDirStack();
47134712
return false;
47144713
}
4715-
_cur = DirEntry(_stack[$-1].dirpath.chompPrefix(_pathPrefix), findinfo);
4714+
_cur = DirEntry(_stack[$-1].dirpath, findinfo);
47164715
return true;
47174716
}
47184717

@@ -4757,8 +4756,6 @@ private struct DirIteratorImpl
47574756

47584757
bool next() @trusted
47594758
{
4760-
import std.string : chompPrefix;
4761-
47624759
if (_stack.length == 0)
47634760
return false;
47644761

@@ -4768,7 +4765,7 @@ private struct DirIteratorImpl
47684765
if (core.stdc.string.strcmp(&fdata.d_name[0], ".") &&
47694766
core.stdc.string.strcmp(&fdata.d_name[0], ".."))
47704767
{
4771-
_cur = DirEntry(_stack[$-1].dirpath.chompPrefix(_pathPrefix), fdata);
4768+
_cur = DirEntry(_stack[$-1].dirpath, fdata);
47724769
return true;
47734770
}
47744771
}
@@ -4798,21 +4795,9 @@ private struct DirIteratorImpl
47984795

47994796
this(string pathname, SpanMode mode, bool followSymlink)
48004797
{
4801-
import std.path : absolutePath, isAbsolute;
4802-
48034798
_mode = mode;
48044799
_followSymlink = followSymlink;
48054800

4806-
if (!pathname.isAbsolute)
4807-
{
4808-
const pathnameRel = pathname;
4809-
alias pathnameAbs = pathname;
4810-
pathname = pathname.absolutePath;
4811-
4812-
const offset = pathnameAbs.length - pathnameRel.length;
4813-
_pathPrefix = pathnameAbs[0 .. offset];
4814-
}
4815-
48164801
if (stepIn(pathname))
48174802
{
48184803
if (_mode == SpanMode.depth)

0 commit comments

Comments
 (0)