Q:

Get script path in Dart (analog __DIR__ constant in PHP)

How I can get path of the current script (not executable) in Dart?
For example. In PHP we have __DIR__ constant, that reffer to script directory. If we have two scripts: ./run.php and ./lib/test.php; and in ./run.php we just include ./lib/test.php. Code in ./lib/test.php output __DIR__. if we run ./run.php then we get in output /path/to/lib/test.php.
In Dart we can get directory of the current run script, but how I can get directory of the current script?
I need in this, because I'm try to get json-file (that placed in library) from the library.
 
How I can do this?

A:

You've said that when you run test.dart, the current directory is /path/to/lib/tests. So you should be able to use a relative path to open rules.json. The path is ../rules/rules.json (or of course, ..\rules\rules.json on Windows, you can get the separator from Platform.pathSeparator).
Alternately, apparently you can get a Uri for the current script (if supported by the platform) from Platform.script.

