<?php
/**
 * CodeIgniter library
 *
 * @category CodeIgniter
 * @author  Christian Koller derived from
 * @author  ExpressionEngine Dev Team
 * @copyright   Copyright (c) 2008, EllisLab, Inc.
 * @license https://codeigniter.com/user_guide/license.html MIT
 * @package libraries
 * @version $Id: My_Loader.php 23543 2022-02-19 18:42:02Z christian $
*/

if (!defined('BASEPATH')) { exit('No direct script access allowed'); }

/**
 * Add's additional functionality to the loader class
 *
 * This allows us to add some of the untermStrich functionality here
 */
class My_Loader extends CI_Loader
{
    /**
     * Load a filesystem object
     *
     * @param   string              $path                Load filesystem object by path
     * @param   Filesystem_access   $filesystem_access   Optional access information
     * @return  object
     */
    public function filesystem($path, Filesystem_access $filesystem_access=null)
    {
        require_once(APPPATHLIVE.'libraries/filesystem_creators/Filesystem_creator.php');

        if (strtoupper(substr($path ?? '', 0, 5)) === Filesystem_creator::FS_O365.':') {
            $type = Filesystem_creator::FS_O365;
        } else { // all others - also ./ (realtive paths)
            $type = Filesystem_creator::FS_LOCAL;
        }
        
        $file_system = $type.'_filesystem_creator';
        require_once(APPPATHLIVE.'libraries/filesystem_creators/'.$file_system.EXT);
        return new $file_system($path ?? '', $filesystem_access);
    }
    
} // END class My_loader
