mirror of
https://github.com/php/php-src.git
synced 2024-11-29 04:46:07 +08:00
MFH: Add stream_supports_lock() function (Benjamin Schulz)
This commit is contained in:
parent
b15f2feda8
commit
cbf466a953
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
PHP NEWS
|
PHP NEWS
|
||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
?? ??? 20??, PHP 5.3.0
|
?? ??? 20??, PHP 5.3.0
|
||||||
|
- Added stream_supports_lock() function (Benjamin Schulz)
|
||||||
- Added msg_queue_exists() function (Benjamin Schulz)
|
- Added msg_queue_exists() function (Benjamin Schulz)
|
||||||
- Added 3 Firebird specific attributes that can be set via PDO::setAttribute()
|
- Added 3 Firebird specific attributes that can be set via PDO::setAttribute()
|
||||||
to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT,
|
to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT,
|
||||||
|
@ -2318,6 +2318,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_stream_is_local, 0)
|
|||||||
ZEND_ARG_INFO(0, stream)
|
ZEND_ARG_INFO(0, stream)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
static
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_supports_lock, 0, 0, 1)
|
||||||
|
ZEND_ARG_INFO(0, stream)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
static
|
static
|
||||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_select, 0, 0, 4)
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_select, 0, 0, 4)
|
||||||
ZEND_ARG_INFO(1, read_streams) /* ARRAY_INFO(1, read_streams, 1) */
|
ZEND_ARG_INFO(1, read_streams) /* ARRAY_INFO(1, read_streams, 1) */
|
||||||
@ -3493,6 +3498,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
|
|||||||
#endif
|
#endif
|
||||||
PHP_FE(stream_copy_to_stream, arginfo_stream_copy_to_stream)
|
PHP_FE(stream_copy_to_stream, arginfo_stream_copy_to_stream)
|
||||||
PHP_FE(stream_get_contents, arginfo_stream_get_contents)
|
PHP_FE(stream_get_contents, arginfo_stream_get_contents)
|
||||||
|
PHP_FE(stream_supports_lock, arginfo_stream_supports_lock)
|
||||||
PHP_FE(fgetcsv, arginfo_fgetcsv)
|
PHP_FE(fgetcsv, arginfo_fgetcsv)
|
||||||
PHP_FE(fputcsv, arginfo_fputcsv)
|
PHP_FE(fputcsv, arginfo_fputcsv)
|
||||||
PHP_FE(flock, arginfo_flock)
|
PHP_FE(flock, arginfo_flock)
|
||||||
|
@ -1375,6 +1375,26 @@ PHP_FUNCTION(stream_is_local)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
/* {{{ proto bool stream_supports_lock(resource stream)
|
||||||
|
Tells wether the stream supports locking through flock(). */
|
||||||
|
PHP_FUNCTION(stream_supports_lock)
|
||||||
|
{
|
||||||
|
php_stream *stream;
|
||||||
|
zval *zsrc;
|
||||||
|
|
||||||
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zsrc) == FAILURE) {
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
php_stream_from_zval(stream, &zsrc);
|
||||||
|
|
||||||
|
if (!php_stream_supports_lock(stream)) {
|
||||||
|
RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SHUTDOWN
|
#ifdef HAVE_SHUTDOWN
|
||||||
/* {{{ proto int stream_socket_shutdown(resource stream, int how)
|
/* {{{ proto int stream_socket_shutdown(resource stream, int how)
|
||||||
causes all or part of a full-duplex connection on the socket associated
|
causes all or part of a full-duplex connection on the socket associated
|
||||||
|
@ -56,6 +56,7 @@ PHP_FUNCTION(stream_socket_enable_crypto);
|
|||||||
PHP_FUNCTION(stream_socket_shutdown);
|
PHP_FUNCTION(stream_socket_shutdown);
|
||||||
PHP_FUNCTION(stream_socket_pair);
|
PHP_FUNCTION(stream_socket_pair);
|
||||||
PHP_FUNCTION(stream_is_local);
|
PHP_FUNCTION(stream_is_local);
|
||||||
|
PHP_FUNCTION(stream_supports_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local variables:
|
* Local variables:
|
||||||
|
44
ext/standard/tests/file/stream_supports_lock.phpt
Normal file
44
ext/standard/tests/file/stream_supports_lock.phpt
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
--TEST--
|
||||||
|
stream_supports_lock
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
var_dump($fp);
|
||||||
|
var_dump(stream_supports_lock($fp));
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fp = fopen("file://" . __FILE__, "r");
|
||||||
|
var_dump($fp);
|
||||||
|
var_dump(stream_supports_lock($fp));
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fp = fopen("php://memory", "r");
|
||||||
|
var_dump($fp);
|
||||||
|
var_dump(stream_supports_lock($fp));
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fp = fopen('data://text/plain,foobar', 'r');
|
||||||
|
var_dump($fp);
|
||||||
|
var_dump(stream_supports_lock($fp));
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$sock = stream_context_create();
|
||||||
|
var_dump($sock);
|
||||||
|
var_dump(stream_supports_lock($sock));
|
||||||
|
|
||||||
|
echo "Done\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
bool(false)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
bool(false)
|
||||||
|
resource(%d) of type (stream-context)
|
||||||
|
|
||||||
|
Warning: stream_supports_lock(): supplied resource is not a valid stream resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
Done
|
Loading…
Reference in New Issue
Block a user