1--TEST--
2Test fopen() function : variation: use include path and stream context create a file, relative path
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--FILE--
6<?php
7/* Prototype  : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
8 * Description: Open a file or a URL and return a file pointer
9 * Source code: ext/standard/file.c
10 * Alias to functions:
11 */
12
13require_once('fopen_include_path.inc');
14
15$thisTestDir =  basename(__FILE__, ".php") . ".dir";
16mkdir($thisTestDir);
17chdir($thisTestDir);
18
19$newpath = relative_include_path();
20set_include_path($newpath);
21runtest();
22
23$newpath = generate_next_rel_path();
24set_include_path($newpath);
25runtest();
26
27teardown_relative_path();
28restore_include_path();
29chdir("..");
30rmdir($thisTestDir);
31
32function runtest() {
33	$tmpfile =  basename(__FILE__, ".php") . ".tmp";
34	$h = fopen($tmpfile, "w", true);
35	fwrite($h, (binary) "This is the test file");
36	fclose($h);
37
38
39	$h = @fopen($tmpfile, "r");
40	if ($h === false) {
41	   echo "Not created in working dir\n";
42	}
43	else {
44	   echo "created in working dir\n";
45	   fclose($h);
46	   unlink($tmpfile);
47	}
48
49	$h = @fopen('dir1/'.$tmpfile, "r");
50	if ($h === false) {
51	   echo "Not created in dir1\n";
52	}
53	else {
54	   echo "created in dir1\n";
55	   fclose($h);
56	   unlink('dir1/'.$tmpfile);
57	}
58}
59?>
60===DONE===
61--EXPECT--
62created in working dir
63Not created in dir1
64created in working dir
65Not created in dir1
66===DONE===
67