/**
 * Private function returning all extracted IMS content package file
 */
function imsc_migrate_get_old_files($path, $relative)
{
    global $OUTPUT;
    $result = array();
    if (!file_exists($path)) {
        echo $OUTPUT->notification("File path doesn't exist: {$path} <br/> Please fix it manually.");
        return array();
    }
    $items = new DirectoryIterator($path);
    foreach ($items as $item) {
        if ($item->isDot() or $item->isLink()) {
            // symbolic links could create infinite loops or cause unintended file migration, sorry
            continue;
        }
        $pathname = $item->getPathname();
        $relname = $relative . '/' . $item->getFilename();
        if ($item->isFile()) {
            $result[$relname] = $pathname;
        } else {
            if ($item->isDir()) {
                $result = array_merge($result, imsc_migrate_get_old_files($pathname, $relname));
            }
        }
        unset($item);
    }
    unset($items);
    return $result;
}
Пример #2
0
/**
 * Private function returning all extracted IMS content package file
 */
function imsc_migrate_get_old_files($path, $relative)
{
    $result = array();
    $items = new DirectoryIterator($path);
    foreach ($items as $item) {
        if ($item->isDot() or $item->isLink()) {
            // symbolik links could create infinite loops or cause unintended file migration, sorry
            continue;
        }
        $pathname = $item->getPathname();
        $relname = $relative . '/' . $item->getFilename();
        if ($item->isFile()) {
            $result[$relname] = $pathname;
        } else {
            if ($item->isDir()) {
                $result = array_merge($result, imsc_migrate_get_old_files($pathname, $relname));
            }
        }
        unset($item);
    }
    unset($items);
    return $result;
}