fopen_variation10-win32.phpt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. --TEST--
  2. Test fopen() function : variation: interesting paths, no use include path
  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:\\fopen_variation10.tmp')) {
  10. die('skip. C:\\ not writable.');
  11. }
  12. ?>
  13. --FILE--
  14. <?php
  15. /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
  16. * Description: Open a file or a URL and return a file pointer
  17. * Source code: ext/standard/file.c
  18. * Alias to functions:
  19. */
  20. echo "*** Testing fopen() : variation ***\n";
  21. // fopen with interesting windows paths.
  22. $testdir = dirname(__FILE__).'/fopen10.tmpDir';
  23. $rootdir = 'fopen10.tmpdirTwo';
  24. mkdir($testdir);
  25. mkdir('c:\\'.$rootdir);
  26. $unixifiedDir = '/'.substr(str_replace('\\','/',$testdir),3);
  27. $paths = array('c:\\',
  28. 'c:',
  29. 'c',
  30. '\\',
  31. '/',
  32. 'c:'.$rootdir,
  33. 'c:adir',
  34. 'c:\\/',
  35. 'c:\\'.$rootdir.'\\/',
  36. 'c:\\'.$rootdir.'\\',
  37. 'c:\\'.$rootdir.'/',
  38. $unixifiedDir,
  39. '/sortout');
  40. $file = "fopen_variation10.tmp";
  41. $firstfile = 'c:\\'.$rootdir.'\\'.$file;
  42. $secondfile = $testdir.'\\'.$file;
  43. $thirdfile = 'c:\\'.$file;
  44. $h = fopen($firstfile, 'w');
  45. fwrite($h, "file in $rootdir");
  46. fclose($h);
  47. $h = fopen($secondfile, 'w');
  48. fwrite($h, "file in fopen10.tmpDir");
  49. fclose($h);
  50. $h = fopen($thirdfile, 'w');
  51. fwrite($h, "file in root");
  52. fclose($h);
  53. foreach($paths as $path) {
  54. echo "\n--$path--\n";
  55. $toFind = $path.'\\'.$file;
  56. $h = fopen($toFind, 'r');
  57. if ($h === false) {
  58. echo "file not opened for read\n";
  59. }
  60. else {
  61. fpassthru($h);
  62. echo "\n";
  63. }
  64. fclose($h);
  65. };
  66. unlink($firstfile);
  67. unlink($secondfile);
  68. unlink($thirdfile);
  69. rmdir($testdir);
  70. rmdir('c:\\'.$rootdir);
  71. ?>
  72. ===DONE===
  73. --EXPECTF--
  74. *** Testing fopen() : variation ***
  75. --c:\--
  76. file in root
  77. --c:--
  78. file in root
  79. --c--
  80. Warning: fopen(c\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
  81. file not opened for read
  82. Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
  83. --\--
  84. Warning: fopen(\\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
  85. file not opened for read
  86. Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
  87. --/--
  88. Warning: fopen(/\fopen_variation10.tmp): failed to open stream: Invalid argument in %s on line %d
  89. file not opened for read
  90. Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
  91. --c:fopen10.tmpdirTwo--
  92. file in fopen10.tmpdirTwo
  93. --c:adir--
  94. Warning: fopen(c:adir\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
  95. file not opened for read
  96. Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
  97. --c:\/--
  98. file in root
  99. --c:\fopen10.tmpdirTwo\/--
  100. file in fopen10.tmpdirTwo
  101. --c:\fopen10.tmpdirTwo\--
  102. file in fopen10.tmpdirTwo
  103. --c:\fopen10.tmpdirTwo/--
  104. file in fopen10.tmpdirTwo
  105. --%s/fopen10.tmpDir--
  106. file in fopen10.tmpDir
  107. --/sortout--
  108. Warning: fopen(/sortout\fopen_variation10.tmp): failed to open stream: No such file or directory in %s on line %d
  109. file not opened for read
  110. Warning: fclose() expects parameter 1 to be resource, boolean given in %s on line %d
  111. ===DONE===