1--TEST--
2Test fopen() function : variation: use include path create and read a file (relative)
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 = create_include_path();
20set_include_path($newpath);
21runtest();
22
23$newpath = generate_next_path();
24set_include_path($newpath);
25runtest();
26
27teardown_include_path();
28chdir("..");
29rmdir($thisTestDir);
30
31function runtest() {
32    global $dir1;
33
34    $extraDir = "extraDir17";
35
36    mkdir($dir1.'/'.$extraDir);
37    mkdir($extraDir);
38
39	$tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".tmp";
40	$h = fopen($tmpfile, "w+", true);
41	fwrite($h, "This is the test file");
42	fclose($h);
43
44	$h = @fopen($dir1.'/'.$tmpfile, "r");
45	if ($h === false) {
46	   echo "Not created in dir1\n";
47	}
48	else {
49	   echo "created in dir1\n";
50	   fclose($h);
51	}
52
53	$h = fopen($tmpfile, "r", true);
54	if ($h === false) {
55	   echo "could not find file for reading\n";
56	}
57	else {
58	   echo "found file for reading\n";
59	   fclose($h);
60	}
61
62	unlink($tmpfile);
63        rmdir($dir1.'/'.$extraDir);
64        rmdir($extraDir);
65}
66?>
67===DONE===
68--EXPECT--
69Not created in dir1
70found file for reading
71Not created in dir1
72found file for reading
73===DONE===
74