1--TEST-- 2Testing fseek() on a directory stream 3--FILE-- 4<?php 5 6// include the file.inc for Function: function create_files() 7require(__DIR__ . '/file.inc'); 8 9$path = __DIR__ . '/fseek_dir_basic'; 10mkdir($path); 11create_files($path, 3); 12 13echo "call readdir():\n"; 14var_dump($dh = opendir($path)); 15$files = array(); 16while( FALSE !== ($files[] = readdir($dh)) ) {} 17sort($files); 18var_dump($files); 19$files = array(); 20 21echo "\ncall fseek() on directory resource:\n"; 22var_dump(fseek($dh, 20)); 23 24echo "call readdir():\n"; 25while( FALSE !== ($files[] = readdir($dh)) ) {} 26sort($files); 27var_dump($files); 28$files = array(); 29 30echo "\ncall fseek() with different arguments on directory resource:\n"; 31var_dump(fseek($dh, 20, SEEK_END)); 32 33echo "call readdir():\n"; 34while( FALSE !== ($files[] = readdir($dh)) ) {} 35sort($files); 36var_dump($files); 37 38delete_files($path, 3); 39closedir($dh); 40var_dump(rmdir($path)); 41 42?> 43--EXPECTF-- 44call readdir(): 45resource(%d) of type (stream) 46array(6) { 47 [0]=> 48 bool(false) 49 [1]=> 50 string(1) "." 51 [2]=> 52 string(2) ".." 53 [3]=> 54 string(9) "file1.tmp" 55 [4]=> 56 string(9) "file2.tmp" 57 [5]=> 58 string(9) "file3.tmp" 59} 60 61call fseek() on directory resource: 62int(0) 63call readdir(): 64array(6) { 65 [0]=> 66 bool(false) 67 [1]=> 68 string(1) "." 69 [2]=> 70 string(2) ".." 71 [3]=> 72 string(9) "file1.tmp" 73 [4]=> 74 string(9) "file2.tmp" 75 [5]=> 76 string(9) "file3.tmp" 77} 78 79call fseek() with different arguments on directory resource: 80int(0) 81call readdir(): 82array(6) { 83 [0]=> 84 bool(false) 85 [1]=> 86 string(1) "." 87 [2]=> 88 string(2) ".." 89 [3]=> 90 string(9) "file1.tmp" 91 [4]=> 92 string(9) "file2.tmp" 93 [5]=> 94 string(9) "file3.tmp" 95} 96bool(true) 97