/usr/share/psychtoolbox-3/PsychInitialize/IsPsychStartupImplantedInStartup.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 | function isImplanted = IsPsychStartupImplantedInStartup
% isImplanted = IsPsychStartupImplantedInStartup
%
% Return TRUE if both the startup.m file is on the MATLAB path and if it
% includes a call to PsychStartup.
%
% If you have your own startup.m file which you want to use, then place it
% ahead of the Psychtoolbox startup.m file on MATLAB's search path and add
% to your file the line:
% PsychStartup; % Setup Psychtoolbox.
% _________________________________________________________________________
commandString='PsychStartup';
commentChar='%';
pth=which('startup.m');
if isempty(pth)
isImplanted=0;
else
%check that the startup file contains the PsychStartup call and don't be
%fooled by commented-out linese. we implement these as a series of filters.
%read the file contents and breack into lines
f=fopen(pth);
cDoubles=fread(f);
fclose(f);
cChars=char(cDoubles');
cLines=BreakLines(cChars);
%find the indices of those lines which contain the the string
%"PsychStartup". These are all candidates but some
% might just be comments.
occuranceIndices=[];
for i =1:length(cLines)
if ~isempty(strfind(cLines{i}, commandString))
occuranceIndices=[occuranceIndices i]; %#ok<*AGROW>
end
end
%build a cell array of the line fragments before the comment character.
nonCommentFragments={};
if length(occuranceIndices) < 1
isImplanted = 0;
return;
end
for i=length(occuranceIndices)
commentCharIndices=find(cLines{occuranceIndices(i)}==commentChar);
if isempty(commentCharIndices);
%add the line to the list of candidate fragments if there is no
%comment character
nonCommentFragments{i}=cLines{occuranceIndices(i)};
else
%add to the list of candidate fragments the portion of the line
%ahead of the comment character if there is one.
temp=cLines{occuranceIndices(i)};
nonCommentFragments{i}=temp(1:commentCharIndices(1));
end
end
%search the list of candidate fragments for the command string. This
%is imperfect because it can be fooled if the command is a substring of
%a longer command. But its probably good enough.
numFoundCalls=0;
foundCallsLineIndices=[];
for i=length(occuranceIndices)
foundIndices=strfind(nonCommentFragments{i},commandString );
if ~isempty(foundIndices)
numFoundCalls = numFoundCalls+1;
foundCallsLineIndices = [foundCallsLineIndices i];
end
end
if numFoundCalls > 1
% we can't print multiline warnings using warning so just print the
% the word "warning"
fprintf('Warning: The startup.m script:\n');
fprintf(['\t' pth '\n']);
fprintf(['seems to call "' commandString '" ' int2str(numFoundCalls) ' times. Only one call is necessary\n']);
end
isImplanted = numFoundCalls;
end
|