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 = "fopenVariation16.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 = "extraDir16";
35
36    mkdir($dir1.'/'.$extraDir);
37    mkdir($extraDir);
38
39	$tmpfile = $extraDir.'/fopen_variation16.tmp';
40
41	$h = fopen($tmpfile, "w+", true);
42	fwrite($h, "This is the test file");
43	fclose($h);
44
45	$h = @fopen($dir1.'/'.$tmpfile, "r");
46	if ($h === false) {
47	   echo "Not created in dir1\n";
48	}
49	else {
50	   echo "created in dir1\n";
51	   fclose($h);
52	}
53
54	$h = fopen($tmpfile, "r", true);
55	if ($h === false) {
56	   echo "could not find file for reading\n";
57	}
58	else {
59	   echo "found file - not in dir1\n";
60	   fclose($h);
61	}
62
63	unlink($tmpfile);
64    rmdir($dir1.'/'.$extraDir);
65    rmdir($extraDir);
66}
67?>
68===DONE===
69--EXPECT--
70Not created in dir1
71found file - not in dir1
72Not created in dir1
73found file - not in dir1
74===DONE===
75