1--TEST--
2Basic long path test with file I/O, multibyte path and realpath() check
3--EXTENSIONS--
4mbstring
5--SKIPIF--
6<?php
7include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
8
9skip_if_not_win();
10if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
11skip_if_no_required_exts();
12
13?>
14--FILE--
15<?php
16$p = "";
17$s = str_repeat('x', 50) . "ü";
18$how_many = 32;
19
20
21for ($i = 0; $i < $how_many; $i++) {
22    $p .= "$s";
23    $p .= DIRECTORY_SEPARATOR;
24}
25
26/* path doesn't exist at this point! */
27$p = realpath(__DIR__) . DIRECTORY_SEPARATOR . $p;
28
29echo strlen($p), "\n", $p, "\n";
30
31var_dump(mkdir($p, 0777, true));
32var_dump(file_exists($p));
33
34/* path exists now, ensure realpath() works! */
35$p2 = realpath($p);
36var_dump($p2);
37/* realpath() will cut off the trailing slash */
38var_dump(substr($p, 0, strlen($p) - 1) == $p2);
39
40$p7 = $p . "hello.txt";
41
42var_dump(file_put_contents($p7, "hello"));
43var_dump(file_get_contents($p7));
44
45unlink($p7);
46
47for ($i = 0; $i < $how_many; $i++) {
48    $p0 = substr($p, 0, strlen($p) - $i*(strlen($s) + 1));
49    rmdir($p0);
50}
51
52var_dump(file_exists(realpath(__DIR__) . DIRECTORY_SEPARATOR . $s));
53
54?>
55--EXPECTF--
56%d%d%d%d
57%s\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxü\xxxxxxxxxx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