stream = php_stream_fopen_tmpfile();
if (stream) {
+ stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
php_stream_to_zval(stream, return_value);
} else {
RETURN_FALSE;
if (stream == NULL) {
RETURN_FALSE;
}
+
+ stream->flags |= PHP_STREAM_FLAG_FCLOSE;
php_stream_to_zval(stream, return_value);
}
PHP_STREAM_TO_ZVAL(stream, arg1);
+
+ if (!(stream->flags & PHP_STREAM_FLAG_FCLOSE)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id);
+ RETURN_FALSE;
+ }
+
if (!stream->is_persistent) {
zend_list_delete(stream->rsrc_id);
} else {
stream = php_stream_xport_create(hostname, hostname_len, ENFORCE_SAFE_MODE | REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, &tv, NULL, &errstr, &err);
+ stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
if (port > 0) {
efree(hostname);
}
zval *retfp;
/* nasty hack; don't copy it */
- stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
+ stream->flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_FCLOSE;
MAKE_STD_ZVAL(retfp);
php_stream_to_zval(stream, retfp);
STREAM_XPORT_CLIENT | (flags & PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) |
(flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? STREAM_XPORT_CONNECT_ASYNC : 0),
hashkey, &tv, context, &errstr, &err);
+
if (stream == NULL) {
/* host might contain binary characters */
RETURN_FALSE;
}
+ stream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
if (errstr) {
efree(errstr);
}
stream = php_stream_xport_create(host, host_len, ENFORCE_SAFE_MODE | REPORT_ERRORS,
STREAM_XPORT_SERVER | flags,
NULL, NULL, context, &errstr, &err);
+
+ stream->flags |= PHP_STREAM_FLAG_FCLOSE;
if (stream == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : errstr);
NULL, NULL,
&tv, &errstr
TSRMLS_CC) && clistream) {
-
+
+ clistream->flags |= PHP_STREAM_FLAG_FCLOSE;
+
if (peername) {
Z_TYPE_P(peername) = IS_STRING;
}
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
// closing the resources
fclose($fp);
-fclose($dfp);
+closedir($dfp);
echo "\n*** Done ***";
?>
#define PHP_STREAM_FLAG_IS_DIR 64
+#define PHP_STREAM_FLAG_FCLOSE 128
+
struct _php_stream {
php_stream_ops *ops;
void *abstract; /* convenience pointer for abstraction */
if (s_err) php_stream_close(s_err);
return;
}
+
+ s_in->flags |= PHP_STREAM_FLAG_FCLOSE;
+ s_out->flags |= PHP_STREAM_FLAG_FCLOSE;
+ s_err->flags |= PHP_STREAM_FLAG_FCLOSE;
#if PHP_DEBUG
/* do not close stdout and stderr */