public function create_directory($newdirname, $userid = NULL) {
        if (!$this->is_writable() or !$this->lf->is_directory()) {
            return null;
        }

        $newdirname = clean_param($newdirname, PARAM_FILE);
        if ($newdirname === '') {
            return null;
        }

        $filepath = $this->lf->get_filepath().'/'.$newdirname.'/';

        $fs = get_file_storage();

        if ($file = $fs->create_directory($this->lf->get_contextid(), $this->lf->get_component(), $this->lf->get_filearea(), $this->lf->get_itemid(), $filepath, $userid)) {
            return $this->browser->get_file_info($this->context, $this->lf->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
        }
        return null;
    }
public function create_directory($newdirname, $userid = NULL) {
        if (!$this->is_writable() or !$this->lf->is_directory()) {
            return null;
        }

        $newdirname = clean_param($newdirname, PARAM_FILE);
        if ($newdirname === '') {
            return null;
        }

        $filepath = $this->lf->get_filepath().'/'.$newdirname.'/';

        $fs = get_file_storage();

        if ($file = $fs->create_directory($this->lf->get_contextid(), $this->lf->get_component(), $this->lf->get_filearea(), $this->lf->get_itemid(), $filepath, $userid)) {
            return $this->browser->get_file_info($this->context, $this->lf->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
        }
        return null;
    }
public function create_directory ( $ newdirname , $ userid = NULL ) { if ( ! $ this -> is_writable ( ) or ! $ this -> lf -> is_directory ( ) ) { return null ; } $ newdirname = clean_param ( $ newdirname , PARAM_FILE ) ; if ( $ newdirname === '' ) { return null ; } $ filepath = $ this -> lf -> get_filepath ( ) . '/' . $ newdirname . '/' ; $ fs = get_file_storage ( ) ; if ( $ file = $ fs -> create_directory ( $ this -> lf -> get_contextid ( ) , $ this -> lf -> get_component ( ) , $ this -> lf -> get_filearea ( ) , $ this -> lf -> get_itemid ( ) , $ filepath , $ userid ) ) { return $ this -> browser -> get_file_info ( $ this -> context , $ this -> lf -> get_component ( ) , $ file -> get_filearea ( ) , $ file -> get_itemid ( ) , $ file -> get_filepath ( ) , $ file -> get_filename ( ) ) ; } return null ; }
Create new directory, may throw exception - make sure
params are valid.

@param string $newdirname name of new directory
@param int $userid id of author, default $USER->id
@return file_info|null new directory's file_info instance or null if failed
Create new directory may throw exception - make sure params are valid .