Hello,
I’m on a project in which I need to get the user’s current working directory. I tried:
- sys.FileSystem.absolutePath(".")
- Sys.programPath() / Sys.executablePath()
- Sys.getCwd()
public static function main() {
trace(Sys.getCwd());
}
I tried with a little project with just a Main.hx and this code snippet is getting well in haxe but not in CPP. In CPP, it returns an empty string.
After some research in forums, I found a “solution” using macros but this one keep the cwd at compilation. This is not what we intend because the program needs to access distributed resources.
public static function main() {
trace(cwd());
}
public static macro function cwd():haxe.macro.Expr.ExprOf<String> {
return macro $v{Sys.getCwd()};
}
If you have any solutions to make Sys.getCwd() work in CPP.
Thanks