44 const XMLNS =
'http://www.erebot.net/xmlns/xglob';
46 const TAG =
'wrapping';
48 public function stream_tell()
50 return $this->position;
53 public function stream_eof()
55 return ($this->position >= strlen($this->content));
58 public function stream_close()
64 public function stream_open($path, $mode, $options, &$openedPath)
67 $pos = strpos($path,
'://');
72 $path = substr($path, $pos + 3);
74 if (strlen($path) < 1) {
78 if (in_array($path[0], array(
"/", DIRECTORY_SEPARATOR))) {
80 } elseif (!strncasecmp(PHP_OS,
"Win", 3) && strlen($path) > 1 && $path[1] ==
':') {
83 $abs = getcwd() . DIRECTORY_SEPARATOR;
86 $abs .= str_replace(
"/", DIRECTORY_SEPARATOR, $path);
87 $matches = glob($abs, 0);
88 if ($matches ===
false) {
92 $content =
'<xglob:'.self::TAG.
' xmlns:xglob="'.self::XMLNS.
'">';
93 foreach ($matches as $absname) {
94 if (!is_file($absname)) {
97 $cnt = file_get_contents($absname);
102 $content .=
'</xglob:'.self::TAG.
'>';
103 $this->content = $content;
107 public function stream_read($count)
109 $ret = substr($this->content, $this->position, $count);
110 $this->position += strlen($ret);
114 public function stream_seek($offset, $whence)
118 if ($offset < strlen($this->content) && $offset >= 0) {
119 $this->position = $offset;
126 $this->position += $offset;
132 $len = strlen($this->content);
133 if ($len + $offset >= 0) {
134 $this->position = $len + $offset;
A stream wrapper which performs a glob on files and returns the content of all matching files...
$content
Content of the stream.
$context
Stream context, set automatically by PHP.
$position
Current position in the stream.