% installer_vijay - Sets up the path for use with packaged software. % % SYNTAX % installer_vijay % installer_vijay(workingdir) % workingdir - The working copy directory in which the Svoboda lab software is located % % NOTES % This function is derived from the setSvobodaLabPaths function created by Tim O'Connor % % This installer assumes that the user will keep all their working copies in a shared folder... % % Created - 6/9/07 Vijay Iyer % Copyright - Howard Hughes Medical Institute 2007 function installer_vijay(install_root) if ~exist('install_root') install_root = uigetdir(matlabroot, 'Choose the working copy directory into which you have installed the software.'); if isempty(install_root) return; end if length(install_root) == 1 if install_root == 0 return; end end end %Hang onto this, because we'll want to check if things are already on the path, so we don't have redundant entries. %If redundancy is allowed, multiple calls to this function would result in a massive path. p = lower(path); %Identify if there are any previous versions installed %Identify parent directory of installed directory origdir = cd; cd(install_root); cd ..; root_parent = cd; cd(origdir); if ~isempty(strfind(p,lower(root_parent))) %Identify directory boundaries in path string dirends = [strfind(p,';')-1 length(p)]; dirstarts = [1 dirends(1:end-1)+2]; %Identify directory boundaries corresponding to previous SvoLab software installation svolabdirs = strfind(p,lower(root_parent)) [junk,dir_indices] = intersect(dirstarts,svolabdirs); %Remove all directories corresponding to previous SvoLab installations for i=1:length(dir_indices) index = dir_indices(i); dir_to_kill = p(dirstarts(dir_indices(i)):dirends(dir_indices(i))); rmpath(dir_to_kill); fprintf(1, 'Removing ''%s'' from the path.\n',dir_to_kill); end end %Refresh path variable p = lower(path); %Specify what to install selections = inputdlg({'Ephus Etc','ScanImage','Physiology','Digital Video'},'Select applications to install (1=Yes,0=No)',1,{'1' '0' '0' '0'}); ephus = str2num(selections{1}); scanimage = str2num(selections{2}); physiology = str2num(selections{3}); digvideo = str2num(selections{4}); lib = [install_root '\svobodalab\library']; progs = [install_root '\svobodalab\Programs']; classes = [install_root '\svobodalab\USERCLASSES']; userfcns = [install_root '\svobodalab\UserFcns']; scripts = [install_root '\SAMPLES\startup scripts\']; scanimage_path = [install_root '\LEGACY\ScanImage']; physiology_path = [install_root '\LEGACY\ScanImage']; digvideo_path = [install_root '\LEGACY\ScanImage']; %Remove any existing %Add Legacy directories first (lowest priority) if needed (VI112806) if scanimage addRecursive(scanimage_path,p); end if physiology addRecursive(physiology_path,p); end if digvideo addRecursive(digvideo_path,p); end addRecursive(lib, p); addRecursive(progs, p); addRecursive(scripts,p); addDir(classes, p); yesOrNo = questdlg('The path can now be saved for use in future sessions. Would you like to do this now?', ... 'Save Path?', 'Yes', 'No', 'Yes'); if strcmpi(yesOrNo, 'Yes') path2rc; end return; %---------------------------------------------- function addDir(name, p) if exist(name) ~= 7 fprintf(2, 'WARNING - Expected directory not found: %s\n', name); return; end fprintf(1, 'Adding ''%s'' to the path.\n', name); if ~isempty(strfind(p, lower(name))) %Remove here, then prepend later, so it takes precedence in the search path. rmpath(name); end addpath(name); return; %---------------------------------------------- function addRecursive(name, p) if exist(name) ~= 7 fprintf(2, 'WARNING - Expected directory not found: %s\n', name); return; end addDir(name, p); d = dir(name); for i = 1 : length(d) if d(i).isdir & ~strcmp(d(i).name, '.') & ~strcmp(d(i).name, '..') & isempty(strfind(d(i).name,'.svn')) %VI112906 addRecursive(fullfile(name, d(i).name), p); end end return;