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: fsgettmppath.m
    path of file: ./repos/brainSurfer/scripts/fs
    
    the code of the file until where you have to start completion: function tmppath = fsgettmppath(tmppathdefault)
% tmppath = fsgettmppath(<tmppathdefault>)
% Gets path to a temporary folder (does NOT generate a random file name)

    
function tmppath = fsgettmppath(tmppathdefault)
% tmppath = fsgettmppath(<tmppathdefault>)
% Gets path to a temporary folder (does NOT generate a random file name)
% First looks in the following order:
%  1. $TMPDIR - env var must exist and folder must exist
%  2. $TEMPDIR - env var must exist and folder must exist
%  3. /scratch - folder must exist
%  4. /tmp - folder must exist
%  5. tmppathdefault - if passed
%  6. current folder, ie, ./ (prints warning)


tmppath = getenv('TMPDIR');
if(~isempty(tmppath)) 
  if(exist(tmppath)) 
    return; 
  end