@@ -157,25 +157,18 @@ PHP_FUNCTION(dir)
157
157
/* }}} */
158
158
159
159
160
- static php_stream * php_dir_get_directory_stream_from_user_arg (zval * arg )
160
+ static php_stream * php_dir_get_directory_stream_from_user_arg (php_stream * dir_stream )
161
161
{
162
- zend_resource * res ;
163
- if (arg == NULL ) {
162
+ if (dir_stream == NULL ) {
164
163
if (UNEXPECTED (DIRG (default_dir ) == NULL )) {
165
164
zend_type_error ("No resource supplied" );
166
165
return NULL ;
167
166
}
168
- res = DIRG (default_dir );
169
- } else {
170
- ZEND_ASSERT (Z_TYPE_P (arg ) == IS_RESOURCE );
171
- res = Z_RES_P (arg );
167
+ zend_resource * res = DIRG (default_dir );
168
+ ZEND_ASSERT (res -> type == php_file_le_stream ());
169
+ dir_stream = (php_stream * ) res -> ptr ;
172
170
}
173
171
174
- if (UNEXPECTED (res -> type != php_file_le_stream ())) {
175
- zend_argument_type_error (1 , "must be a valid Directory resource" );
176
- return NULL ;
177
- }
178
- php_stream * dir_stream = (php_stream * ) res -> ptr ;
179
172
if (UNEXPECTED ((dir_stream -> flags & PHP_STREAM_FLAG_IS_DIR )) == 0 ) {
180
173
zend_argument_type_error (1 , "must be a valid Directory resource" );
181
174
return NULL ;
@@ -209,14 +202,14 @@ static php_stream* php_dir_get_directory_stream_from_this(zval *this_z)
209
202
/* {{{ Close directory connection identified by the dir_handle */
210
203
PHP_FUNCTION (closedir )
211
204
{
212
- zval * id = NULL ;
205
+ php_stream * dirp = NULL ;
213
206
214
207
ZEND_PARSE_PARAMETERS_START (0 , 1 )
215
208
Z_PARAM_OPTIONAL
216
- Z_PARAM_RESOURCE_OR_NULL ( id )
209
+ PHP_Z_PARAM_STREAM_OR_NULL ( dirp )
217
210
ZEND_PARSE_PARAMETERS_END ();
218
211
219
- php_stream * dirp = php_dir_get_directory_stream_from_user_arg (id );
212
+ dirp = php_dir_get_directory_stream_from_user_arg (dirp );
220
213
if (UNEXPECTED (dirp == NULL )) {
221
214
RETURN_THROWS ();
222
215
}
@@ -249,14 +242,14 @@ PHP_METHOD(Directory, close)
249
242
/* {{{ Rewind dir_handle back to the start */
250
243
PHP_FUNCTION (rewinddir )
251
244
{
252
- zval * id = NULL ;
245
+ php_stream * dirp = NULL ;
253
246
254
247
ZEND_PARSE_PARAMETERS_START (0 , 1 )
255
248
Z_PARAM_OPTIONAL
256
- Z_PARAM_RESOURCE_OR_NULL ( id )
249
+ PHP_Z_PARAM_STREAM_OR_NULL ( dirp )
257
250
ZEND_PARSE_PARAMETERS_END ();
258
251
259
- php_stream * dirp = php_dir_get_directory_stream_from_user_arg (id );
252
+ dirp = php_dir_get_directory_stream_from_user_arg (dirp );
260
253
if (UNEXPECTED (dirp == NULL )) {
261
254
RETURN_THROWS ();
262
255
}
@@ -280,14 +273,14 @@ PHP_METHOD(Directory, rewind)
280
273
/* {{{ Read directory entry from dir_handle */
281
274
PHP_FUNCTION (readdir )
282
275
{
283
- zval * id = NULL ;
276
+ php_stream * dirp = NULL ;
284
277
285
278
ZEND_PARSE_PARAMETERS_START (0 , 1 )
286
279
Z_PARAM_OPTIONAL
287
- Z_PARAM_RESOURCE_OR_NULL ( id )
280
+ PHP_Z_PARAM_STREAM_OR_NULL ( dirp )
288
281
ZEND_PARSE_PARAMETERS_END ();
289
282
290
- php_stream * dirp = php_dir_get_directory_stream_from_user_arg (id );
283
+ dirp = php_dir_get_directory_stream_from_user_arg (dirp );
291
284
if (UNEXPECTED (dirp == NULL )) {
292
285
RETURN_THROWS ();
293
286
}
0 commit comments