This file is indexed.

/usr/share/psychtoolbox-3/PsychCal/CalDataFolder.m is in psychtoolbox-3-common 3.0.11.20140816.dfsg1-1.

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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
function directory=CalDataFolder(forceDemo,calFileName,calDir)
% directory=CalDataFolder([forceDemo],[calFileName],[calDir])
%
% Get the path to the CalData folder.
%
% If "forceDemo" is true (false by default), then force use of
% PsychCalDemoData.  Otherwise return location of PsychCalLocalData
% if it exists, and PsychCalDemoData if it PsychCalLocalData does
% not exist.
%
% If calFileName is passed, it checks if the specified file exists
% in the top level of the directory it located.  If so, it returns
% that directory.  If not, it searches the first level subdirectories
% of the top level directories and if the specfied file is in one of
% them, returns that.  Skips subdirs called 'xOld', 'Plots', and those
% that begin with '.'.
%
% calFileName can either have .mat postpended or not.
%
% If calDir is passed as a string, that is used as the directory, with
% the subdir searching as above.
%
% See also LoadCalFile, SaveCalFile.
%
% Denis Pelli 7/25/96
% Denis Pelli 2/28/98 change "CalDat" to "PsychCalData"
% 8/14/00  dhb  Add alternate name, change names. 
% 4/1/07   dhb  Fix subtle bug in error message when there are duplicate cal
%               folders on path. 
% 3/7/08   mpr  changed documentation to make it consistent (apparently
%               "forceDemo" used to be "alt"
% 4/2/13   dhb  Add calFileName and associated behavior.
% 6/2/13   dhb  Make this properly return subfolder containing calibration file
%               if .mat is not postpended.
% 6/10/13  dhb  Fix buglet introduced 6/2/13 -- need to handle empty calFileName (thanks to MS for
%               identifying the problem and the fix.

% Set forceDemo flag
if (nargin < 1 || isempty(forceDemo))
	forceDemo = 0;
end
if (nargin < 2 || isempty(calFileName))
    calFileName = [];
end

% Postpend .mat if necessary
if (~isempty(calFileName) && ~strcmp(calFileName(end-3:end),'.mat'))
    calFileName = [calFileName '.mat'];
end

% If dir is passed we just use that.  Otherwise
% do our thing.
if (nargin < 3 || isempty(calDir)) 
    name='PsychCalLocalData';
    alternateName ='PsychCalDemoData';
    
    % Find name.  If not there, find alternate
    if (~forceDemo)
        directory = FindFolder(name);
        duplicateMsgName = name;
    else
        directory = [];
    end
    if isempty(directory)
        directory=FindFolder(alternateName);
        duplicateMsgName = alternateName;
    end
    
    % If both finds fail, print out error message.  This
    % should never happen as we put 'PsychCalDemoData' in
    % the toolbox distribution.
    if isempty(directory)
        error(['Can''t find any ''' name ''' or ''' alternateName '''folders in the Matlab path.']);
    end
    
    % If we found multiple copies of a calibration folder, we complain.
    % This also should never happen.
    if size(directory,1)>1
        for i=1:size(directory,1)
            disp(['DUPLICATE: ''' deblank(directory(i,:)) '''']);
        end
        error(['Found more than one ''' duplicateMsgName ''' folder in the Matlab path.']);
    end
else
    directory = calDir;
end

% If we were passed a calibration file name, figure out whether it exists in
% the found directory, or a subfolder of the directory.
if (~isempty(calFileName))
    curDir = pwd;
    cd(directory);
    
    % Is the file we're after here?  If so, we're good
    % and we just return after restoring directory.
    % Otherwise, we look in any subdirectories other
    % than those beginning with 'xOld' or 'Plot' and
    % see if our baby is there.
    foundOne = 0;
    dirRet = dir([calFileName]);
    if (~isempty(dirRet))
        foundOne = 1;
    end
    allDirs = dir;
    for i = 1:length(allDirs)
        if (allDirs(i).isdir && ~strcmp(allDirs(i).name,'xOld') && ~strcmp(allDirs(i).name,'Plots') && allDirs(i).name(1) ~= '.')
            cd(allDirs(i).name);
            dirRet = dir(calFileName);
            cd('..');
            if (~isempty(dirRet))
                if (foundOne)
                    error('More than one copy of the desired calibration file found');
                end
                directory = [directory allDirs(i).name filesep];
                foundOne = 1;
            end
        end
    end
    
    cd(curDir);
end