1

Say I have following file structure of my application:

Data/prefs.ini
executable.exe

How can I open prefs.ini providing relative path to it from executable.exe is always the same (known at compile time)? Or how can I get absolute path of executable.exe? I need it to work on Linux, Mac and Windows.

wildfireheart
  • 373
  • 2
  • 4
  • 13

1 Answers1

2

There is an exact haxe API for that: Sys.executablePath() (doc)

To get a path relative to it:

import haxe.io.Path;
class Test {
    static public function relToExe(path:String):String {
        return Path.join([Path.directory(Sys.executablePath()), path]);
    }
    static function main() {
        trace(relToExe("something"));
    }
}
Andy Li
  • 5,894
  • 6
  • 37
  • 47