ZEND_ARG_INFO(0, stream)
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
ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_select, 0, 0, 4)
ZEND_ARG_INFO(1, read_streams) /* ARRAY_INFO(1, read_streams, 1) */
#endif
PHP_FE(stream_copy_to_stream, arginfo_stream_copy_to_stream)
PHP_FE(stream_get_contents, arginfo_stream_get_contents)
+ PHP_FE(stream_supports_lock, arginfo_stream_supports_lock)
PHP_FE(stream_resolve_include_path, arginfo_stream_resolve_include_path)
PHP_FE(fgetcsv, arginfo_fgetcsv)
PHP_FE(fputcsv, arginfo_fputcsv)
}
/* }}} */
+/* {{{ 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
/* {{{ proto int stream_socket_shutdown(resource stream, int how) U
causes all or part of a full-duplex connection on the socket associated
PHP_FUNCTION(stream_socket_pair);
PHP_FUNCTION(stream_resolve_include_path);
PHP_FUNCTION(stream_is_local);
+PHP_FUNCTION(stream_supports_lock);
/*
* Local variables:
--- /dev/null
+--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