You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: getContents.m
    path of file: ./repos/CellExplorer/toolboxes/+iosr/+general
    
    the code of the file until where you have to start completion: function [cont,dirflag] = getContents(directory,varargin)
%GETCONTENTS Get the contents of a specified directory
%
%   This function returns the contents of a specified directory.
%
%   CONT = IOSR.GENERAL.GETCONTENTS(DIRECTORY) returns the files and
%   folders in a directory and returns them to the cell array cont. It
%   ignores hidden files and folders (those starting '.'). DIRECTORY must
%   be a character array (string).
% 
%   CONT = IOSR.GENERAL.GETCONTENTS(DIRECTORY,'PARAMETER',VALUE) allows
%   search options to be specified. The options include:
%       'rec'       {false} | true
%                   Search recursively within the subfolders of the
%                   specified directory.
%       'path'      {'relative'} | 'full'
%                   Specifies whether returned paths are full or relative
%                   to the specified directory.
%       'sort'      {false} | true
%                   Specify whether the output is sorted alphabetically.
%       'filter'    {'all'} | 'files' | 'folders' | '*.ext' | str
%                   This option allows a filter to be specified. 'files'
%                   returns names of all files in the directory. 'folders'

    
function [cont,dirflag] = getContents(directory,varargin)
%GETCONTENTS Get the contents of a specified directory
%
%   This function returns the contents of a specified directory.
%
%   CONT = IOSR.GENERAL.GETCONTENTS(DIRECTORY) returns the files and
%   folders in a directory and returns them to the cell array cont. It
%   ignores hidden files and folders (those starting '.'). DIRECTORY must
%   be a character array (string).
% 
%   CONT = IOSR.GENERAL.GETCONTENTS(DIRECTORY,'PARAMETER',VALUE) allows
%   search options to be specified. The options include:
%       'rec'       {false} | true
%                   Search recursively within the subfolders of the
%                   specified directory.
%       'path'      {'relative'} | 'full'
%                   Specifies whether returned paths are full or relative
%                   to the specified directory.
%       'sort'      {false} | true
%                   Specify whether the output is sorted alphabetically.
%       'filter'    {'all'} | 'files' | 'folders' | '*.ext' | str
%                   This option allows a filter to be specified. 'files'
%                   returns names of all files in the directory. 'folders'
%                   returns names of all folders in the directory. '*.ext',
%                   where 'ext' is a user-specified file extension, returns
%                   all files with the extension '.ext'. str may be any
%                   string; only elements that contain str will be returned
%                   (files or folders). str is case-sensitive.
% 
%   [CONT,DIRFLAG] = IOSR.GENERAL.GETCONTENTS(...) returns a logical array
%   DIRFLAG, the same size as CONT, indicating whether each element is a
%   directory.
% 
%   Examples
% 
%       Ex. 1
% 
%       % Return all m-files in the current directory
% 
%       cont = iosr.general.getContents(cd,'filter','*.m')
% 
%       Ex. 2
% 
%       % Return all files in the current directory and its
%       % sub-directories
% 
%       cont = iosr.general.getContents(cd,'rec',true)
% 
%       Ex. 3
% 
%       % Return all files in current directory with names
%       % containing 'foo'
%       
%       % may return files and folders:
%       [cont,dirflag] = iosr.general.getContents(cd,'filter','foo')
% 
%       % use dirflag to limit:
%       cont = cont(~dirflag);

%   Copyright 2016 University of Surrey.

    % parse input arguments and arrange call(s) to 'main', which
    % does the actual searching of directories

    assert(ischar(directory), 'iosr:getContents:invalidDir', 'directory must be a character array')

    % Switch trap parses the varargin inputs
    % default values
    recflag = false;
    pathflag = 'relative';
    sortflag = false;
    str = 'all';
    % find values
    for i = 1:2:length(varargin)
        switch lower(varargin{i})
            case 'path'
                pathflag=varargin{i+1};
            case 'rec'
                recflag=varargin{i+1};
            case 'sort'
                sortflag=varargin{i+1};
            case 'filter'
                str=varargin{i+1};
            otherwise
                error('iosr:getContents:unknownOption','Unknown option: %s\n',varargin{i});
        end