fopen_variation11-win32.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. --TEST--
  2. Test fopen() function : variation: interesting paths, use include path = true
  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 Run only on Windows");
  9. if (!is_writable('c:\\')) {
  10. die('skip. C:\\ not writable.');
  11. }
  12. ?>
  13. --FILE--
  14. <?php
  15. echo "*** Testing fopen() : variation ***\n";
  16. // fopen with interesting windows paths.
  17. $testdir = __DIR__.'/fopen11.tmpDir';
  18. $rootdir = 'fopen11.tmpdirTwo';
  19. mkdir($testdir);
  20. mkdir('c:\\'.$rootdir);
  21. $unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
  22. $paths = array('c:\\',
  23. 'c:',
  24. 'c',
  25. '\\',
  26. '/',
  27. 'c:'.$rootdir,
  28. 'c:adir',
  29. 'c:\\/',
  30. 'c:\\'.$rootdir.'\\/',
  31. 'c:\\'.$rootdir.'\\',
  32. 'c:\\'.$rootdir.'/',
  33. $unixifiedDir,
  34. '/sortout');
  35. $file = "fopen_variation11.tmp";
  36. $firstfile = 'c:\\'.$rootdir.'\\'.$file;
  37. $secondfile = $testdir.'\\'.$file;
  38. $thirdfile = 'c:\\'.$file;
  39. $h = fopen($firstfile, 'w');
  40. fwrite($h, "file in $rootdir");
  41. fclose($h);
  42. $h = fopen($secondfile, 'w');
  43. fwrite($h, "file in fopen11.tmpDir");
  44. fclose($h);
  45. $h = fopen($thirdfile, 'w');
  46. fwrite($h, "file in root");
  47. fclose($h);
  48. foreach($paths as $path) {
  49. echo "\n--$path--\n";
  50. $toFind = $path.'\\'.$file;
  51. $h = fopen($toFind, 'r', true);
  52. if ($h === false) {
  53. echo "file not opened for read\n";
  54. }
  55. else {
  56. fpassthru($h);
  57. fclose($h);
  58. echo "\n";
  59. }
  60. };
  61. unlink($firstfile);
  62. unlink($secondfile);
  63. unlink($thirdfile);
  64. rmdir($testdir);
  65. rmdir('c:\\'.$rootdir);
  66. ?>
  67. --EXPECTF--
  68. *** Testing fopen() : variation ***
  69. --c:\--
  70. file in root
  71. --c:--
  72. file in root
  73. --c--
  74. Warning: fopen(c\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
  75. file not opened for read
  76. --\--
  77. Warning: fopen(\\FOPEN_VARIATION11.TMP): Failed to open stream: No such file or directory in %s on line %d
  78. file not opened for read
  79. --/--
  80. Warning: fopen(\\FOPEN_VARIATION11.TMP): Failed to open stream: No such file or directory in %s on line %d
  81. file not opened for read
  82. --c:fopen11.tmpdirTwo--
  83. file in fopen11.tmpdirTwo
  84. --c:adir--
  85. Warning: fopen(c:adir\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
  86. file not opened for read
  87. --c:\/--
  88. file in root
  89. --c:\fopen11.tmpdirTwo\/--
  90. file in fopen11.tmpdirTwo
  91. --c:\fopen11.tmpdirTwo\--
  92. file in fopen11.tmpdirTwo
  93. --c:\fopen11.tmpdirTwo/--
  94. file in fopen11.tmpdirTwo
  95. --%s/fopen11.tmpDir--
  96. file in fopen11.tmpDir
  97. --/sortout--
  98. Warning: fopen(/sortout\fopen_variation11.tmp): Failed to open stream: No such file or directory in %s on line %d
  99. file not opened for read