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:54:22 +08:00
parent 8d6dde0805
commit b5b18eb572
+5 -3
View File
@@ -749,7 +749,7 @@ abstract class testing_util {
if (file_exists(self::get_dataroot() . '/filedir')) {
$handle = opendir(self::get_dataroot() . '/filedir');
while (false !== ($item = readdir($handle))) {
if (in_array('filedir/' . $item, $childclassname::$datarootskiponreset)) {
if (in_array('filedir' . DIRECTORY_SEPARATOR . $item, $childclassname::$datarootskiponreset)) {
continue;
}
if (is_dir(self::get_dataroot()."/filedir/$item")) {
@@ -961,8 +961,10 @@ abstract class testing_util {
if (!file_exists($jsonfilepath)) {
$listfiles = array();
$listfiles['filedir/.'] = 'filedir/.';
$listfiles['filedir/..'] = 'filedir/..';
$currentdir = 'filedir' . DIRECTORY_SEPARATOR . '.';
$parentdir = 'filedir' . DIRECTORY_SEPARATOR . '..';
$listfiles[$currentdir] = $currentdir;
$listfiles[$parentdir] = $parentdir;
$filedir = self::get_dataroot() . '/filedir';
if (file_exists($filedir)) {