home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / IOFUN.DI$ / TEMPDIR.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  749 b   |  28 lines

  1. function tmp_dir = tempdir()
  2. %TEMPDIR Returns the name of the temporary directory if one exists
  3.  
  4. %    Marc Ullman  2-8-93
  5. %    Copyright (C) 1984-93 by The MathWorks, Inc.
  6.  
  7. comp = [computer '   '];
  8. if (comp(1:2) =='PC')
  9.     tmp_dir = getenv('TEMP');        % Microsoft's recommended name
  10.     if ( isempty(tmp_dir) )
  11.         tmp_dir = getenv('TMP');    % What everybody else uses
  12.     end
  13.     if ( ~isempty(tmp_dir) )
  14.         % Make sure name ends with a valid path separator
  15.         last_char = tmp_dir(length(tmp_dir));
  16.         if ((last_char ~= '\') & (last_char ~= '/'))
  17.             tmp_dir = [tmp_dir '\'];
  18.         end
  19.     end
  20. elseif (comp(1:3) == 'MAC')
  21.     tmp_dir = '';
  22. elseif (comp(4:6) == 'VMS')
  23.     tmp_dir = 'SYS$SCRATCH:';
  24. else
  25.     % Assume we are on a UNIX system
  26.     tmp_dir = '/tmp/';
  27. end
  28.