mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
some extra type checks
This commit is contained in:
parent
bd77a24550
commit
782e09ec62
8 changed files with 24 additions and 13 deletions
|
|
@ -47,7 +47,6 @@ class UrlCallback extends Wrapper implements Url {
|
|||
* @return \Icewind\Streams\Path
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function wrap($source, $fopen = null, $opendir = null, $mkdir = null, $rename = null, $rmdir = null,
|
||||
$unlink = null, $stat = null) {
|
||||
|
|
@ -78,21 +77,29 @@ class UrlCallback extends Wrapper implements Url {
|
|||
public function stream_open($path, $mode, $options, &$opened_path) {
|
||||
$context = $this->loadUrlContext($path);
|
||||
$this->callCallBack($context, 'fopen');
|
||||
$this->setSourceStream(fopen($context['source'], $mode));
|
||||
$source = fopen($context['source'], $mode);
|
||||
if ($source === false) {
|
||||
return false;
|
||||
}
|
||||
$this->setSourceStream($source);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function dir_opendir($path, $options) {
|
||||
$context = $this->loadUrlContext($path);
|
||||
$this->callCallBack($context, 'opendir');
|
||||
$this->setSourceStream(opendir($context['source']));
|
||||
$source = opendir($context['source']);
|
||||
if ($source === false) {
|
||||
return false;
|
||||
}
|
||||
$this->setSourceStream($source);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function mkdir($path, $mode, $options) {
|
||||
$context = $this->loadUrlContext($path);
|
||||
$this->callCallBack($context, 'mkdir');
|
||||
return mkdir($context['source'], $mode, $options & STREAM_MKDIR_RECURSIVE);
|
||||
return mkdir($context['source'], $mode, ($options & STREAM_MKDIR_RECURSIVE) > 0);
|
||||
}
|
||||
|
||||
public function rmdir($path, $options) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue