Getting path of currently executing file from within stream_opener handler
| From: | Marshall Greenblatt | Date: | Sat, 17 Nov 2007 08:23:06 +0000 |
| Subject: | Getting path of currently executing file from within stream_opener handler | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-33218@lists.php.net to get a copy of this message | ||
Hi All,
I have a stream wrapper implementation that needs to properly resolve
relative paths. For example, say I have a file structure like the
following:
file1.php
dir/file2.php
dir/file3.php
file4.php
file1.php contains: <?php include 'dir/file2.php'; ?>
file2.php contains: <?php include 'file3.php; ?>
My implementation of php_stream_wrapper_ops.stream_opener will see a
path value of "dir/file2.php" for the first include request and a path
value of "file3.php" for the second include request. When receiving
the second include request, I need to know that the file currently
being processed is "dir/file2.php" so that I can properly resolve
"file3.php" to "dir/file3.php". I can't simply "remember" the
last
value passed to stream_opener because I have no way of knowing when
processing of a particular file has ended. For instance:
file1.php contains: <?php include 'dir/file2.php'; include 'file4.php'; ?>
file2.php contains: <?php include 'file3.php; ?>
Is there a method that can be used from within the stream_opener
handler function to retrieve the path of the file currently being
processed? Alternately, is there a way to hook into the code
processing routines so that I can keep track of when execution of a
particular file begins and ends? Or is there an even better option
that I'm missing?
Any thoughts would be greatly appreciated :-).
Thanks,
Marshall