view m-toolbox/classes/+utils/@helper/remove_svn_from_matlabpath.m @ 5:5a49956df427 database-connection-manager

LTPDAPreferences panel for new LTPDADatabaseConnectionManager
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% newpath = remove_svn_from_matlabpath(oldpath)
%
% An utility function to remove .svn folders from the given path
% If no output is provided, it will use and set the current Matlab path
% 
% D Nicolodi 25/03/2011
%
% VERSION:    $Id: remove_svn_from_matlabpath.m,v 1.2 2011/03/25 15:11:40 mauro Exp $
%

function newpath = remove_svn_from_matlabpath(oldpath)
  
  % if no path given load current matlab path
  if nargin < 1
    oldpath = matlabpath();
  end
  
  newpath = '';
  while true
    % split path definition into components
    [p, oldpath] = strtok(oldpath,pathsep);
    if isempty(p)
      break;
    end
    % remove components if it contais .svn
    if isempty(findstr(p,'.svn'))
      newpath = [newpath,pathsep,p];
    end
  end
  % remove initial pathsep
  newpath = newpath(2:end);
  
  % if no path given set the new path as the current one
  if nargin < 1
    path(newpath);
  end
  
end