mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12325] Use \RecursiveDirectoryIterator
PHPBB3-12325
This commit is contained in:
parent
cd5129f261
commit
e4beea0c1e
1 changed files with 18 additions and 37 deletions
|
@ -325,19 +325,19 @@ class build_package
|
||||||
$result = array();
|
$result = array();
|
||||||
$file_contents = file($deleted_filename);
|
$file_contents = file($deleted_filename);
|
||||||
|
|
||||||
foreach ($file_contents as $line)
|
foreach ($file_contents as $filename)
|
||||||
{
|
{
|
||||||
$line = trim($line);
|
$filename = trim($filename);
|
||||||
|
|
||||||
if (!$line)
|
if (!$filename)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$line = str_replace('Only in ' . $package_name, '', $line);
|
$filename = str_replace('Only in ' . $package_name, '', $filename);
|
||||||
$line = ltrim($line, '/');
|
$filename = ltrim($filename, '/');
|
||||||
|
|
||||||
if (substr($line, 0, 1) == ':')
|
if (substr($filename, 0, 1) == ':')
|
||||||
{
|
{
|
||||||
$replace = '';
|
$replace = '';
|
||||||
}
|
}
|
||||||
|
@ -346,45 +346,26 @@ class build_package
|
||||||
$replace = '/';
|
$replace = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$line = str_replace(': ', $replace, $line);
|
$filename = str_replace(': ', $replace, $filename);
|
||||||
|
|
||||||
if (is_dir("{$this->locations['old_versions']}{$package_name}/{$line}"))
|
if (is_dir("{$this->locations['old_versions']}{$package_name}/{$filename}"))
|
||||||
{
|
{
|
||||||
$result = array_merge($result, $this->get_files_recursive("{$this->locations['old_versions']}{$package_name}/{$line}", $line));
|
$iterator = new \RecursiveIteratorIterator(
|
||||||
}
|
new \RecursiveDirectoryIterator(
|
||||||
else
|
"{$this->locations['old_versions']}{$package_name}/{$filename}",
|
||||||
{
|
\FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS
|
||||||
$result[] = $line;
|
),
|
||||||
}
|
\RecursiveIteratorIterator::LEAVES_ONLY
|
||||||
}
|
);
|
||||||
|
|
||||||
return $result;
|
foreach ($iterator as $file_info)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get recursively the list of the files contained in a directory
|
|
||||||
*
|
|
||||||
* @param string $directory_absolute Absolute path to the directory
|
|
||||||
* @param string $directory Relative path to the directory (used to prefixed the name of the files)
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function get_files_recursive($directory_absolute, $directory)
|
|
||||||
{
|
{
|
||||||
$result = array();
|
$result[] = "{$filename}/{$iterator->getSubPathname()}";
|
||||||
$files = scandir($directory_absolute);
|
|
||||||
|
|
||||||
foreach ($files as $file)
|
|
||||||
{
|
|
||||||
if (is_dir($directory_absolute . '/' . $file))
|
|
||||||
{
|
|
||||||
if ($file != '.' && $file != '..')
|
|
||||||
{
|
|
||||||
$result = array_merge($result, $this->get_files_recursive($directory_absolute . '/' . $file, $directory . '/' . $file));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result[] = $directory . '/' . $file;
|
$result[] = $filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue