Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)
pushd ( directory, silent ) ;
function pushd ( directory, silent ) ; Script to simulate unix commands PUSHD and POPD in matlab SILENT : do not show DIR_STACK after processing, if defined ----------------------------------- Alexis Lau (7/8/93)
| This function calls | This function is called by |
|---|---|
function pushd ( directory, silent ) ;
global DIR_STACK
nl = char(10);
cwd = pwd;
if strcmp(cwd(1:8), '/tmp_mnt');
cwd = cwd(9:end);
end
if ~strcmp(cwd(length(cwd)),nl);
cwd = [ cwd nl ];
end
if ~exist('directory');
popd('silent'); directory = pwd;
end;
if ~isstr(directory);
error('directoryectory name must be a string');
elseif strcmp(directory(1),'~')
user = getenv('USER');
if length(directory)==1
directory = [ '/usr/users/' user ];
elseif strcmp(directory(1:2),'~/')
directory = [ '/usr/users/' user '/' directory(3:length(directory)) ];
else
directory = [ '/usr/users/' directory(2:length(directory)) ];
end
end
if ~strcmp(directory(length(directory)),nl);
directory = [ directory nl ];
end
eval(['cd ' directory]);
DIR_STACK = [ cwd DIR_STACK ];
if ~exist('silent'); DIR_STACK, end;