Skip to content

Commit

Permalink
std.file: Use simpler dirent reading closer to C API
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Dec 14, 2018
1 parent cb1dd9f commit e86df01
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -3861,16 +3861,12 @@ else version (Posix)
import std.path : buildPath;
import std.string : representation;

static if (is(typeof(fd.d_reclen)))
{
immutable len = (() @trusted => cast(char*) fd + fd.d_reclen - &fd.d_name[0])();
_name = buildPath(path, (() @trusted => (&fd.d_name[0])[0 .. len])());
}
static if (is(typeof(fd.d_namlen)))
immutable len = fd.d_namlen;
else
{
immutable len = (() @trusted => core.stdc.string.strlen(&fd.d_name[0]))();
_name = buildPath(path, fd.d_name[0 .. len]);
}
immutable len = (() @trusted => core.stdc.string.strlen(fd.d_name.ptr))();

_name = buildPath(path, (() @trusted => fd.d_name.ptr[0 .. len])());

_didLStat = false;
_didStat = false;
Expand Down

0 comments on commit e86df01

Please sign in to comment.