/usr/share/psychtoolbox-3/PsychFiles/FindFolder.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | function directory=FindFolder(name)
% directory=FindFolder(name)
% Searches the Matlab 'path' for the path to the named folder.
% There may be no matches, one match, or multiple matches.
% Each unique match appears as a row in "directory".
% If there are no matches then "directory" will be an empty matrix.
% Matching ignores case.
% You should DEBLANK a row of "directory" before using it.
%
% Also see Matlab's MKDIR, TEMPDIR, ISDIR, LOOKFOR, WHAT.
% Try HELP PsychFiles.
% 7/26/96 dgp Wrote it.
% 12/10/01 awi Set ignoreCase to 1 always.
% 4/13/02 dgp Updated to use Matlab's predefined separator symbols.
% Matlab predefines these:
% PATHSEP = path separator character
% FILESEP = directory separator character
ignoreCase=1;
paths=[path pathsep];
if ignoreCase
n=lower(name);
p=lower(paths);
else
n=name;
p=paths;
end
pathIndex=[1 1+findstr(pathsep,p)];
nameIndex=[findstr([filesep n filesep],p) findstr([filesep n pathsep],p)];
clear n p
if isempty(nameIndex)
directory=[];
else
nIndex=nameIndex(1);
pIndex=pathIndex(max(find(pathIndex<=nIndex)));
directory=[paths(pIndex:nIndex+length(name)) filesep];
for i=2:length(nameIndex)
nIndex=nameIndex(i);
pIndex=pathIndex(max(find(pathIndex<=nIndex)));
new=[paths(pIndex:nIndex+length(name)) filesep];
unique=1;
for j=1:size(directory,1)
if streq(deblank(directory(j,:)),new)
unique=0;
break
end
end
if unique
directory=char(directory,new);
end
end
end
% FindFolder always succeeds. "directory" will have zero to many rows,
% each row containing a unique match.
% What follows is optional code that you may want to add to your program, after
% it calls FindFolder, to give an error unless there was exactly one match.
if 0
if isempty(directory)
error(['Can''t find any ''' name ''' folder in the Matlab path.']);
end
if size(directory,1)>1
for i=1:size(directory,1)
disp(['DUPLICATE: ''' deblank(directory(i,:)) '''']);
end
error(['Found more than one ''' name ''' folder in the Matlab path.']);
end
end
|