1--TEST--
2RecursiveDirectoryIterator with dir path long or of edge case length
3--SKIPIF--
4<?php
5include __DIR__ . DIRECTORY_SEPARATOR . "util.inc";
6
7skip_if_not_win();
8
9if (strlen(__DIR__) > 259) die("skip Unsuitable starting path length");
10?>
11--FILE--
12<?php
13
14$need_len = 1024;
15//$need_len = 259;
16$dir = __DIR__;
17while ($need_len - strlen($dir) > 32) {
18	$dir .= DIRECTORY_SEPARATOR . str_repeat("a", 32);
19}
20$dir .= DIRECTORY_SEPARATOR . str_repeat("a", $need_len - strlen($dir));
21mkdir($dir, 0700, true);
22
23$fl = $dir . DIRECTORY_SEPARATOR . "hello.txt";
24file_put_contents($fl, "");
25
26
27$start = substr($dir, 0, strpos($dir, DIRECTORY_SEPARATOR, strlen(__DIR__)+1));
28$iter = new RecursiveIteratorIterator(
29	new RecursiveDirectoryIterator(
30		$start,
31		FilesystemIterator::SKIP_DOTS
32	),
33	RecursiveIteratorIterator::CHILD_FIRST
34);
35
36foreach ($iter as $item) {
37	if (!$item->isDir()) {
38		var_dump($item->getPathname());
39	}
40}
41
42$iter->rewind();
43foreach ($iter as $item) {
44	if ($item->isDir()) {
45		rmdir($item->getPathname());
46	} else {
47		unlink($item->getPathname());
48	}
49}
50rmdir($start);
51var_dump(file_exists($start));
52
53/*unlink($fl);
54do {
55	rmdir($dir);
56	$dir = dirname($dir);
57} while (__DIR__ != $dir);*/
58
59?>
60==DONE==
61--EXPECTF--
62string(%d) "%shello.txt"
63bool(false)
64==DONE==
65