mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/12273] Use RecursiveDirectoryIterator in md_exporter
PHPBB3-12273
This commit is contained in:
parent
6aa8596d4d
commit
7a44f66448
1 changed files with 16 additions and 16 deletions
|
@ -377,14 +377,21 @@ class md_exporter
|
||||||
* Works recursive with any depth
|
* Works recursive with any depth
|
||||||
*
|
*
|
||||||
* @param string $dir Directory to go through
|
* @param string $dir Directory to go through
|
||||||
* @param string $path Path from root to $dir
|
|
||||||
* @return array List of files (including directories)
|
* @return array List of files (including directories)
|
||||||
*/
|
*/
|
||||||
public function get_recursive_file_list($dir, $path = '')
|
public function get_recursive_file_list($dir)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$iterator = new \DirectoryIterator($dir);
|
$iterator = new \RecursiveIteratorIterator(
|
||||||
|
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||||
|
new \RecursiveDirectoryIterator(
|
||||||
|
$dir,
|
||||||
|
\FilesystemIterator::SKIP_DOTS
|
||||||
|
)
|
||||||
|
),
|
||||||
|
\RecursiveIteratorIterator::SELF_FIRST
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
@ -394,24 +401,17 @@ class md_exporter
|
||||||
$files = array();
|
$files = array();
|
||||||
foreach ($iterator as $file_info)
|
foreach ($iterator as $file_info)
|
||||||
{
|
{
|
||||||
/** @var \DirectoryIterator $file_info */
|
/** @var \RecursiveDirectoryIterator $file_info */
|
||||||
if ($file_info->isDot())
|
if ($file_info->isDir())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not scan some directories
|
$relative_path = $iterator->getInnerIterator()->getSubPathname();
|
||||||
if ($file_info->isDir())
|
|
||||||
|
if (substr($relative_path, -5) == '.html')
|
||||||
{
|
{
|
||||||
$sub_dir = $this->get_recursive_file_list($file_info->getPath() . '/' . $file_info->getFilename(), $path . '/' . $file_info->getFilename());
|
$files[] = str_replace(DIRECTORY_SEPARATOR, '/', $relative_path);
|
||||||
foreach ($sub_dir as $file)
|
|
||||||
{
|
|
||||||
$files[] = $file_info->getFilename() . '/' . $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (substr($file_info->getFilename(), -5) == '.html')
|
|
||||||
{
|
|
||||||
$files[] = $file_info->getFilename();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue