Home > vbmeg > external > iso2mesh > mwpath.m

mwpath

PURPOSE ^

SYNOPSIS ^

function tempname=mwpath(fname)

DESCRIPTION ^

 tempname=meshtemppath(fname)

 get full temp-file name by prepend working-directory and current session name

 author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu)

 input:
    fname: input, a file name string

 output:
    tempname: output, full file name located in the working directory

    if global variable ISO2MESH_TEMP is set in 'base', it will use it
    as the working directory; otherwise, will use matlab function tempdir
    to return a working directory.

    if global variable ISO2MESH_SESSION is set in 'base', it will be
    prepended for each file name, otherwise, use supplied file name.

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tempname=mwpath(fname)
0002 %
0003 % tempname=meshtemppath(fname)
0004 %
0005 % get full temp-file name by prepend working-directory and current session name
0006 %
0007 % author: Qianqian Fang (fangq <at> nmr.mgh.harvard.edu)
0008 %
0009 % input:
0010 %    fname: input, a file name string
0011 %
0012 % output:
0013 %    tempname: output, full file name located in the working directory
0014 %
0015 %    if global variable ISO2MESH_TEMP is set in 'base', it will use it
0016 %    as the working directory; otherwise, will use matlab function tempdir
0017 %    to return a working directory.
0018 %
0019 %    if global variable ISO2MESH_SESSION is set in 'base', it will be
0020 %    prepended for each file name, otherwise, use supplied file name.
0021 %
0022 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0023 %
0024 
0025 p=getvarfrom({'caller','base'},'ISO2MESH_TEMP');
0026 session=getvarfrom({'caller','base'},'ISO2MESH_SESSION');
0027 
0028 username=getenv('USER'); % for Linux/Unix/Mac OS
0029 
0030 if(isempty(username))
0031    username=getenv('UserName'); % for windows
0032 end
0033 
0034 if(~isempty(username))
0035    username=['iso2mesh-' username];
0036 end
0037 
0038 tempname=[];
0039 if(isempty(p))
0040       if(isoctavemesh & tempdir=='\')
0041         tempname=['.'  filesep session fname];
0042     else
0043         tdir=tempdir;
0044         if(tdir(end)~=filesep)
0045             tdir=[tdir filesep];
0046         end
0047         if(~isempty(username))
0048                     tdir=[tdir username filesep];
0049                     if(exist(tdir)==0) mkdir(tdir); end
0050         end
0051         if(nargin==0)
0052             tempname=tdir;
0053         else
0054             tempname=[tdir session fname];
0055         end
0056     end
0057 else
0058     tempname=[p filesep session fname];
0059 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005