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: gotoDir.m
    path of file: ./repos/bspm/thirdparty/rsatoolbox/Engines
    
    the code of the file until where you have to start completion: function gotoDir(varargin)

% gotoDir(path, dir)
%     Goes to path; then goes to dir, making it if necessary.
%
% gotoDir(path)
%     Goes to path, making all required directories on the way.

    
function gotoDir(varargin)

% gotoDir(path, dir)
%     Goes to path; then goes to dir, making it if necessary.
%
% gotoDir(path)
%     Goes to path, making all required directories on the way.
%__________________________________________________________________________
% Copyright (C) 2010 Medical Research Council

switch nargin
	case 2
		path = varargin{1};
		dir = varargin{2};

		try
			cd(path)
		catch
			error('gotoDir:NonexistantPath', ['The path "' path '" does not refer!']);
		end%try
		
		try
			cd(dir);
		catch
			disp(['The directory "' dir '" doesn''t exist at "' path '"; making it.']);
			mkdir(dir);
			cd(dir);
		end%try

	case 1

		path = varargin{1};
		sIndices = strfind(path, filesep);
		
		for i = 1:numel(sIndices)
		
			if i == 1 && sIndices(i) == 1
				continue;
			end