On Monday, 8 April 2019 at 18:47:42 UTC, 4544fa8d wrote:
On Monday, 8 April 2019 at 18:41:00 UTC, Adam D. Ruppe wrote:
Did you put your code inside a main() function?
I want to make constant with path to directory containing
executable. This line is above main():
-----------------------------
const ROOT_DIR = dirName(thisExePath());
-----------------------------
This is not allowed? :O
That would give you dmd's path, if it worked.
This is allowed:
#! /usr/bin/env rdmd
import std.stdio, std.path, std.file;
@property
string root_dir() {
static string cache;
static bool isInit = false;
if (!isInit) {
isInit = true;
cache = dirName(thisExePath());
}
return cache;
}
void main() {
writeln(root_dir);
}