MDL-55174 core_testing: Use proper directory separator

While searching for existing files if directory
separator is not correct then original files
and directories will be deleted. So use DIRECTORY_SEPARATOR.
This commit is contained in:
Rajesh Taneja 2016-07-15 13:51:33 +08:00
parent 36a19ecc26
commit fc2e137750

View file

@ -798,7 +798,7 @@ abstract class testing_util {
if (file_exists(self::get_dataroot() . '/filedir')) { if (file_exists(self::get_dataroot() . '/filedir')) {
$handle = opendir(self::get_dataroot() . '/filedir'); $handle = opendir(self::get_dataroot() . '/filedir');
while (false !== ($item = readdir($handle))) { while (false !== ($item = readdir($handle))) {
if (in_array('filedir/' . $item, $childclassname::$datarootskiponreset)) { if (in_array('filedir' . DIRECTORY_SEPARATOR . $item, $childclassname::$datarootskiponreset)) {
continue; continue;
} }
if (is_dir(self::get_dataroot()."/filedir/$item")) { if (is_dir(self::get_dataroot()."/filedir/$item")) {
@ -1054,8 +1054,10 @@ abstract class testing_util {
if (!file_exists($jsonfilepath)) { if (!file_exists($jsonfilepath)) {
$listfiles = array(); $listfiles = array();
$listfiles['filedir/.'] = 'filedir/.'; $currentdir = 'filedir' . DIRECTORY_SEPARATOR . '.';
$listfiles['filedir/..'] = 'filedir/..'; $parentdir = 'filedir' . DIRECTORY_SEPARATOR . '..';
$listfiles[$currentdir] = $currentdir;
$listfiles[$parentdir] = $parentdir;
$filedir = self::get_dataroot() . '/filedir'; $filedir = self::get_dataroot() . '/filedir';
if (file_exists($filedir)) { if (file_exists($filedir)) {