In the include() impl we could do something conceptually like:
var oldFile = include.__FILE__;
var name = file-we-are-about-to-include;
jsIncludeFunctionObject.__FILE__ = name;
includePrivateImpl( name ); // inside the file, access include.__FILE__
include.__FILE__ = oldFile;
That would of course only work properly only if the code accessing
include.__FILE__ is executed during the execution of include(), as opposed
to being tucked away in a function which is not called during the include()
phase.
The intent is to give include()d scripts a way to include other scripts
without having to fuss with paths.
include() should also arguably chdir() to the file's directory before
inclusion (which makes most uses of __FILE__ obsolute. It doesn't currently
do that only because i never wanted to write the path-parsing code (and
test it thoroughly and hope it works on other platforms).
Original issue reported on code.google.com by sgbeal@googlemail.com on 7 Apr 2010 at 4:32
Original issue reported on code.google.com by
sgbeal@googlemail.com
on 7 Apr 2010 at 4:32