unlink_variation2-win32.phpt 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Test unlink() function : usage variations - unlink file in use
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die('skip only on Windows');
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : bool unlink ( string $filename [, resource $context] );
  12. Description : Deletes filename
  13. */
  14. /* Try to unlink file when file handle is still in use */
  15. $file_path = dirname(__FILE__);
  16. echo "*** Testing unlink() on a file when file handle is open ***\n";
  17. // temp file name used here
  18. $filename = "$file_path/unlink_variation2-win32.tmp";
  19. // create file
  20. $fp = fopen($filename, "w");
  21. // try unlink() on $filename
  22. var_dump( unlink($filename) ); // expected: false as file handle is still open
  23. // now close file handle
  24. fclose($fp);
  25. // now unlink file
  26. var_dump( unlink($filename) ); // expected: true
  27. var_dump( file_exists($filename) ); // confirm file is deleted
  28. echo "Done\n";
  29. ?>
  30. --EXPECTF--
  31. *** Testing unlink() on a file when file handle is open ***
  32. Warning: unlink(%s): %s in %s on line %d
  33. bool(false)
  34. bool(true)
  35. bool(false)
  36. Done