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