File: AddToMatlabPathDynamically.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (29 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function AddToMatlabPathDynamically(directory)
% AddToMatlabPathDynamically(directory)
%
% Add the directory and its subdirectories to Matlab's path, dynamically,
% with strippint out of .svn and .git directories.
% 
% Use for putting routines onto path that are specifict to a particular
% project, without them staying around and clogging up the name space.
%
% Typical usages:
% a) When getting version info
%   exp.mFileName = mfilename;
%   [exp.versionInfo,exp.codeDir] = GetAllVersionInfo(exp.mFileName);
%   AddToMatlabPathDynamically(exp.codeDir);
%
% b) Direct call
%   AddToMatlabPathDynamically( fileparts(which(mfilename))); 
%
% 7/12/13  dhb  Wrote it.
% 7/25/14  dhb  Make independent of BrainardLab idiosyncracies.

%% Dynamically add the program code to the path if it isn't already on it.
if isempty(strfind(path, directory))
	fprintf('- Adding %s dynamically to the path...', directory);
    thePath = RemoveMatchingPaths(genpath(directory),[filesep '.svn']);
    thePath = RemoveMatchingPaths(thePath,[filesep '.git']);
	addpath(thePath, '-end');
	fprintf('Done\n');
end