Annotation of embedaddon/php/ext/standard/tests/dir/readdir_variation6.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test readdir() function : usage variations - operate on previously opened directory
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string readdir([resource $dir_handle])
                      6:  * Description: Read directory entry from dir_handle 
                      7:  * Source code: ext/standard/dir.c
                      8:  */
                      9: 
                     10: /*
                     11:  * Open two directory handles on the same directory and pass both
                     12:  * to readdir() to test behaviour
                     13:  */
                     14: 
                     15: echo "*** Testing readdir() : usage variations ***\n";
                     16: 
                     17: // include the file.inc for Function: function create_files()
                     18: include( dirname(__FILE__)."/../file/file.inc");
                     19: 
                     20: // create the temporary directory
                     21: $dir_path = dirname(__FILE__) . "/readdir_variation6";
                     22: mkdir($dir_path);
                     23: 
                     24: // create files within the temporary directory
                     25: create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "readdir_variation6");
                     26: 
                     27: // open the directory
                     28: $dir_handle1 = opendir($dir_path);
                     29: 
                     30: // open the same directory again without closing it
                     31: opendir($dir_path);
                     32: 
                     33: echo "\n-- Reading Directory Contents with Previous Handle --\n";
                     34: $a = array();
                     35: while (FALSE !== ($file = readdir($dir_handle1))) {
                     36:        $a[] = $file;
                     37: }
                     38: sort($a);
                     39: foreach ($a as $file) {
                     40:        var_dump($file);
                     41: }
                     42: 
                     43: echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n";
                     44: $a = array();
                     45: while (FALSE !== ($file = readdir())) {
                     46:        $a[] = $file;
                     47: }
                     48: sort($a);
                     49: foreach ($a as $file) {
                     50:        var_dump($file);
                     51: }
                     52: 
                     53: // delete temporary files
                     54: delete_files($dir_path, 3, "readdir_variation6");
                     55: closedir($dir_handle1);
                     56: closedir();
                     57: ?>
                     58: ===DONE===
                     59: --CLEAN--
                     60: <?php
                     61: $dir_path = dirname(__FILE__) . "/readdir_variation6";
                     62: rmdir($dir_path);
                     63: ?>
                     64: --EXPECTF--
                     65: *** Testing readdir() : usage variations ***
                     66: 
                     67: -- Reading Directory Contents with Previous Handle --
                     68: string(1) "."
                     69: string(2) ".."
                     70: string(23) "readdir_variation61.tmp"
                     71: string(23) "readdir_variation62.tmp"
                     72: string(23) "readdir_variation63.tmp"
                     73: 
                     74: -- Reading Directory Contents with Current Handle (no arguments supplied) --
                     75: string(1) "."
                     76: string(2) ".."
                     77: string(23) "readdir_variation61.tmp"
                     78: string(23) "readdir_variation62.tmp"
                     79: string(23) "readdir_variation63.tmp"
                     80: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>