Skip to content

Commit

Permalink
Switch to stdlib thisExePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihails Strasuns committed Jun 9, 2019
1 parent 26d5a53 commit d0af824
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions source/simpleconfig/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public void readConfiguration (S) (ref S dst)
import std.process : environment;
import std.exception : ifThrown;
import std.path : dirName;
import std.file : thisExePath;

auto executable = currentProcessBinary();
auto executable = thisExePath();

string[] locations = [
".",
Expand All @@ -38,29 +39,6 @@ public void readConfiguration (S) (ref S dst)
}
}

/**
Returns: fully-qualified filesystem path to the currently running executable
*/
private string currentProcessBinary ()
{
import std.process : thisProcessID;

version (Windows)
{
import core.sys.windows.winbase : GetModuleFileNameA;

char[1024] buffer;
auto ln = GetModuleFileNameA(null, buffer.ptr, buffer.length);
return buffer[0 .. ln].idup;
}
else version (Posix)
{
import std.file : readLink;
import std.format;
return readLink(format("/proc/%s/exe", thisProcessID()));
}
}

private template resolveName (alias Field)
{
import std.traits;
Expand Down

0 comments on commit d0af824

Please sign in to comment.