• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/file_temp.php
  • Класс: CTempFile
  • Вызов: CTempFile::Cleanup
static function Cleanup()
{
	foreach(self::$arFiles as $temp_path => $temp_dir)
	{
		if(file_exists($temp_path))
		{
			//Clean a file from CTempFile::GetFileName('some.jpg');
			if(is_file($temp_path))
			{
				unlink($temp_path);
				@rmdir($temp_dir);
			}
			//Clean whole temporary directory from CTempFile::GetFileName('');
			elseif(
				mb_substr($temp_path, -1) == '/'
				&& strpos($temp_path, "BXTEMP") === false
				&& is_dir($temp_path)
			)
			{
				CTempFile::_absolute_path_recursive_delete($temp_path);
			}
		}
		elseif(file_exists($temp_dir))
		{
			@rmdir($temp_dir);
		}
	}

	//Clean directories with $hours_to_keep_files > 0
	$dir_name = self::GetAbsoluteRoot()."/";
	if (file_exists($dir_name))
	{
		if ($handle = opendir($dir_name))
		{
			while (($day_files_dir = readdir($handle)) !== false)
			{
				if ($day_files_dir == '.' || $day_files_dir == '..')
					continue;
				if (preg_match("/^BXTEMP-(.*?)$/", $day_files_dir) && is_dir($dir_name.$day_files_dir))
				{
					CTempFile::_process_directory($dir_name, $day_files_dir);
				}
			}
			closedir($handle);
		}
	}
}