mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-04 00:54:08 +02:00
more robust supressing of warning
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
0700f81441
commit
9790501e26
1 changed files with 8 additions and 1 deletions
|
|
@ -28,7 +28,14 @@ abstract class Wrapper implements File, Directory {
|
||||||
protected static function wrapSource($source, $context, $protocol, $class) {
|
protected static function wrapSource($source, $context, $protocol, $class) {
|
||||||
try {
|
try {
|
||||||
stream_wrapper_register($protocol, $class);
|
stream_wrapper_register($protocol, $class);
|
||||||
if (@rewinddir($source) === false) {
|
// there is no way to check if a resource is a directory or file handle expect trying to use it as one or the other
|
||||||
|
// and check for errors
|
||||||
|
// we need to suppress error reporting since we expect a warning every time this is called with a file handle
|
||||||
|
$reportingLevel = error_reporting();
|
||||||
|
error_reporting(0);
|
||||||
|
$isFileHandle = rewinddir($source) === false;
|
||||||
|
error_reporting($reportingLevel);
|
||||||
|
if ($isFileHandle) {
|
||||||
$wrapped = fopen($protocol . '://', 'r+', false, $context);
|
$wrapped = fopen($protocol . '://', 'r+', false, $context);
|
||||||
} else {
|
} else {
|
||||||
$wrapped = opendir($protocol . '://', $context);
|
$wrapped = opendir($protocol . '://', $context);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue