From d0af8248c34c55187770052e03e101652c17e7d4 Mon Sep 17 00:00:00 2001 From: Mihails Strasuns Date: Sun, 9 Jun 2019 09:23:01 +0000 Subject: [PATCH] Switch to stdlib thisExePath --- source/simpleconfig/file.d | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/source/simpleconfig/file.d b/source/simpleconfig/file.d index 749c8b2..96ce036 100644 --- a/source/simpleconfig/file.d +++ b/source/simpleconfig/file.d @@ -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 = [ ".", @@ -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;