005_variation2-win32.phpt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --TEST--
  2. Test fileatime(), filemtime(), filectime() & touch() functions : usage 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 for Windows');
  9. }
  10. ?>
  11. --FILE--
  12. <?php
  13. /*
  14. Prototype: int fileatime ( string $filename );
  15. Description: Returns the time the file was last accessed, or FALSE
  16. in case of an error. The time is returned as a Unix timestamp.
  17. Prototype: int filemtime ( string $filename );
  18. Description: Returns the time the file was last modified, or FALSE
  19. in case of an error.
  20. Prototype: int filectime ( string $filename );
  21. Description: Returns the time the file was last changed, or FALSE
  22. in case of an error. The time is returned as a Unix timestamp.
  23. Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
  24. Description: Attempts to set the access and modification times of the file
  25. named in the filename parameter to the value given in time.
  26. */
  27. /*
  28. Prototype: void stat_fn(string $filename);
  29. Description: Prints access, modification and change times of a file
  30. */
  31. function stat_fn( $filename ) {
  32. echo "\n-- File '$filename' --\n";
  33. echo "-- File access time is => ";
  34. echo fileatime($filename)."\n";
  35. clearstatcache();
  36. echo "-- File modification time is => ";
  37. echo filemtime($filename)."\n";
  38. clearstatcache();
  39. echo "-- inode change time is => ";
  40. echo filectime($filename)."\n";
  41. clearstatcache();
  42. }
  43. echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
  44. echo "\n*** testing file info ***";
  45. stat_fn(NULL);
  46. stat_fn(false);
  47. stat_fn('');
  48. stat_fn(' ');
  49. stat_fn('|');
  50. echo "\n*** testing touch ***";
  51. var_dump(touch(NULL));
  52. var_dump(touch(false));
  53. var_dump(touch(''));
  54. //php generates permission denied, we generate No such file or dir.
  55. var_dump(touch(' '));
  56. var_dump(touch('|'));
  57. echo "Done";
  58. ?>
  59. --EXPECTF--
  60. *** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
  61. *** testing file info ***
  62. -- File '' --
  63. -- File access time is =>
  64. -- File modification time is =>
  65. -- inode change time is =>
  66. -- File '' --
  67. -- File access time is =>
  68. -- File modification time is =>
  69. -- inode change time is =>
  70. -- File '' --
  71. -- File access time is =>
  72. -- File modification time is =>
  73. -- inode change time is =>
  74. -- File ' ' --
  75. -- File access time is =>
  76. Warning: fileatime(): stat failed for in %s on line %d
  77. -- File modification time is =>
  78. Warning: filemtime(): stat failed for in %s on line %d
  79. -- inode change time is =>
  80. Warning: filectime(): stat failed for in %s on line %d
  81. -- File '|' --
  82. -- File access time is =>
  83. Warning: fileatime(): stat failed for | in %s on line %d
  84. -- File modification time is =>
  85. Warning: filemtime(): stat failed for | in %s on line %d
  86. -- inode change time is =>
  87. Warning: filectime(): stat failed for | in %s on line %d
  88. *** testing touch ***bool(false)
  89. bool(false)
  90. bool(false)
  91. Warning: touch(): %s in %s on line %d
  92. bool(false)
  93. Warning: touch(): %s in %s on line %d
  94. bool(false)
  95. Done