Home > atmlab > files > path_replace_tilde.m

path_replace_tilde

PURPOSE ^

PATH_REPLACE_TILDE Replace tilde with full home directory path

SYNOPSIS ^

function outpath = path_replace_tilde(inpath)

DESCRIPTION ^

 PATH_REPLACE_TILDE Replace tilde with full home directory path

 If inpath starts with ~/ or contains only ~, it is replaced by the full
 home directory path. If not or getenv('HOME') is empty, the
 unmodified path is returned.

 IN     inpath            String or cell array of strings with paths
 OUT    outpath           New path

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

path_replace_tilde.m

SOURCE CODE ^

0001 function outpath = path_replace_tilde(inpath)
0002 % PATH_REPLACE_TILDE Replace tilde with full home directory path
0003 %
0004 % If inpath starts with ~/ or contains only ~, it is replaced by the full
0005 % home directory path. If not or getenv('HOME') is empty, the
0006 % unmodified path is returned.
0007 %
0008 % IN     inpath            String or cell array of strings with paths
0009 % OUT    outpath           New path
0010 
0011 
0012 % 20110-05-02 Created by Oliver Lemke
0013 
0014 if (~numel(getenv('HOME')))
0015     outpath = inpath;
0016 else
0017     outpath = regexprep( ...
0018         inpath, ...
0019         ['^(~' filesep() ')|(~$)'], ...
0020         [getenv('HOME') filesep], 'once');
0021 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005