1--TEST--
2Test unlink() function : usage variations - unlink file in use
3--SKIPIF--
4<?php
5if (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
15/* Try to unlink file when file handle is still in use */
16
17$file_path = dirname(__FILE__);
18
19echo "*** Testing unlink() on a file when file handle is open ***\n";
20// temp file name used here
21$filename = "$file_path/unlink_variation2-win32.tmp";
22
23// create file
24$fp = fopen($filename, "w");
25// try unlink() on $filename
26var_dump( unlink($filename) );  // expected: false as file handle is still open
27// now close file handle
28fclose($fp);
29
30// now unlink file
31var_dump( unlink($filename) );  // expected: true
32var_dump( file_exists($filename) );  // confirm file is deleted
33
34echo "Done\n";
35?>
36--EXPECTF--
37*** Testing unlink() on a file when file handle is open ***
38
39Warning: unlink(%s): %s in %s on line %d
40bool(false)
41bool(true)
42bool(false)
43Done
44