tempnam_variation1-win32-mb.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. --TEST--
  2. Test tempnam() function: usage variations - creating files
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) != "WIN")
  6. die("skip Only valid for Windows");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Creating number of unique files by passing a file name as prefix */
  11. $file_path = __DIR__."/tempnamVar1_私はガラスを食べられます";
  12. mkdir($file_path);
  13. echo "*** Testing tempnam() in creation of unique files ***\n";
  14. for($i=1; $i<=10; $i++) {
  15. echo "-- Iteration $i --\n";
  16. $files[$i] = tempnam("$file_path", "tempnam_variation1.tmp");
  17. if( file_exists($files[$i]) ) {
  18. echo "File name is => ";
  19. print($files[$i]);
  20. echo "\n";
  21. echo "File permissions are => ";
  22. printf("%o", fileperms($files[$i]) );
  23. echo "\n";
  24. clearstatcache();
  25. echo "File created in => ";
  26. $file_dir = dirname($files[$i]);
  27. if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) {
  28. echo "temp dir\n";
  29. }
  30. else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) {
  31. echo "directory specified\n";
  32. }
  33. else {
  34. echo "unknown location\n";
  35. }
  36. clearstatcache();
  37. }
  38. else {
  39. print("- File is not created -");
  40. }
  41. }
  42. for($i=1; $i<=10; $i++) {
  43. unlink($files[$i]);
  44. }
  45. rmdir($file_path);
  46. echo "*** Done ***\n";
  47. ?>
  48. --EXPECTF--
  49. *** Testing tempnam() in creation of unique files ***
  50. -- Iteration 1 --
  51. File name is => %s%et%s
  52. File permissions are => 100666
  53. File created in => directory specified
  54. -- Iteration 2 --
  55. File name is => %s%et%s
  56. File permissions are => 100666
  57. File created in => directory specified
  58. -- Iteration 3 --
  59. File name is => %s%et%s
  60. File permissions are => 100666
  61. File created in => directory specified
  62. -- Iteration 4 --
  63. File name is => %s%et%s
  64. File permissions are => 100666
  65. File created in => directory specified
  66. -- Iteration 5 --
  67. File name is => %s%et%s
  68. File permissions are => 100666
  69. File created in => directory specified
  70. -- Iteration 6 --
  71. File name is => %s%et%s
  72. File permissions are => 100666
  73. File created in => directory specified
  74. -- Iteration 7 --
  75. File name is => %s%et%s
  76. File permissions are => 100666
  77. File created in => directory specified
  78. -- Iteration 8 --
  79. File name is => %s%et%s
  80. File permissions are => 100666
  81. File created in => directory specified
  82. -- Iteration 9 --
  83. File name is => %s%et%s
  84. File permissions are => 100666
  85. File created in => directory specified
  86. -- Iteration 10 --
  87. File name is => %s%et%s
  88. File permissions are => 100666
  89. File created in => directory specified
  90. *** Done ***