Annotation of embedaddon/php/ext/standard/tests/file/readfile_variation8-win32.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test readfile() function : variation 
                      3: --CREDITS--
                      4: Dave Kelsey <d_kelsey@uk.ibm.com>
                      5: --SKIPIF--
                      6: <?php
                      7: if(substr(PHP_OS, 0, 3) != "WIN")
                      8:   die("skip Only valid for Windows");
                      9: ?>
                     10: --FILE--
                     11: <?php
                     12: /* Prototype  : int readfile(string filename [, bool use_include_path[, resource context]])
                     13:  * Description: Output a file or a URL 
                     14:  * Source code: ext/standard/file.c
                     15:  * Alias to functions: 
                     16:  */
                     17: 
                     18: echo "*** Testing readfile() : variation ***\n";
                     19: $mainDir = "readfileVar8";
                     20: $subDir = "readfileVar8Sub";
                     21: $absMainDir = dirname(__FILE__)."\\".$mainDir;
                     22: mkdir($absMainDir);
                     23: $absSubDir = $absMainDir."\\".$subDir;
                     24: mkdir($absSubDir);
                     25: 
                     26: $theFile = "fileToRead.tmp";
                     27: $absFile = $absSubDir.'/'.$theFile;
                     28: 
                     29: // create the file
                     30: $h = fopen($absFile,"w");
                     31: fwrite($h, "The File Contents");
                     32: fclose($h);
                     33: 
                     34: 
                     35: $old_dir_path = getcwd();
                     36: chdir(dirname(__FILE__));
                     37: $unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
                     38: 
                     39: $allDirs = array(
                     40:   // absolute paths
                     41:   "$absSubDir\\",
                     42:   "$absSubDir\\..\\".$subDir,
                     43:   "$absSubDir\\\\..\\.\\".$subDir,
                     44:   "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
                     45:   "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
                     46:   "$absSubDir\\BADDIR",
                     47:   
                     48:   // relative paths
                     49:   $mainDir."\\".$subDir,
                     50:   $mainDir."\\\\".$subDir, 
                     51:    $mainDir."\\\\\\".$subDir, 
                     52:   ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
                     53:   "BADDIR",  
                     54:   
                     55:   // unixifed path
                     56:   $unixifiedDir,
                     57: );
                     58: 
                     59: for($i = 0; $i<count($allDirs); $i++) {
                     60:   $j = $i+1;
                     61:   $dir = $allDirs[$i];
                     62:   echo "\n-- $dir --\n";
                     63:   $ok = readfile($dir.'\\'.$theFile);
                     64:   if ($ok === 1) {
                     65:      echo "\n";
                     66:   }
                     67: }
                     68: 
                     69: unlink($absFile);
                     70: chdir($old_dir_path);
                     71: rmdir($absSubDir);
                     72: rmdir($absMainDir);
                     73: 
                     74: echo "\n*** Done ***\n";
                     75: ?>
                     76: --EXPECTF--
                     77: *** Testing readfile() : variation ***
                     78: 
                     79: -- %s\readfileVar8\readfileVar8Sub\ --
                     80: The File Contents
                     81: -- %s\readfileVar8\readfileVar8Sub\..\readfileVar8Sub --
                     82: The File Contents
                     83: -- %s\readfileVar8\readfileVar8Sub\\..\.\readfileVar8Sub --
                     84: The File Contents
                     85: -- %s\readfileVar8\readfileVar8Sub\..\..\readfileVar8\.\readfileVar8Sub --
                     86: The File Contents
                     87: -- %s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub --
                     88: 
                     89: Warning: readfile(%s\readfileVar8\readfileVar8Sub\..\\\readfileVar8Sub\\..\\..\readfileVar8Sub\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
                     90: 
                     91: -- %s\readfileVar8\readfileVar8Sub\BADDIR --
                     92: 
                     93: Warning: readfile(%s\readfileVar8\readfileVar8Sub\BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
                     94: 
                     95: -- readfileVar8\readfileVar8Sub --
                     96: The File Contents
                     97: -- readfileVar8\\readfileVar8Sub --
                     98: The File Contents
                     99: -- readfileVar8\\\readfileVar8Sub --
                    100: The File Contents
                    101: -- .\readfileVar8\..\readfileVar8\readfileVar8Sub --
                    102: The File Contents
                    103: -- BADDIR --
                    104: 
                    105: Warning: readfile(BADDIR\fileToRead.tmp): failed to open stream: No such file or directory in %s on line %d
                    106: 
                    107: -- /%s/readfileVar8/readfileVar8Sub --
                    108: The File Contents
                    109: *** Done ***

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