/usr/share/psychtoolbox-3/PsychCal/FlushCalFile.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 | function FlushCalFile(filespec,nKeep)
% FlushCalFile([filespec],[nKeep])
%
% Flush all but the most recent calibrations in a file.
%
% If no filespec is given, flushes file default.mat. If
% a an integer is given, flushes file screenN.mat. If
% a string is given, loads from string.mat.
%
% Argument nKeep specifies how many calibrations to
% keep. If fewer than nKeep are in the file, all are
% kept. If nKeep is zero, file is emptied. nKeep
% defaults to 1.
%
% If specified file cannot be found does nothing.
%
% 8/26/97 dhb Wrote it.
% 8/21/00 dhb Update for dual cal dir scheme. Not tested hard.
% Set nKeep
if (nargin < 2 || isempty(nKeep))
nKeep = 1;
end
% Set the filename
if (nargin < 1 || isempty(filespec))
filename = [CalDataFolder 'default.mat'];
elseif (ischar(filespec))
filename = [CalDataFolder filespec '.mat'];
else
filename = [CalDataFolder sprintf('screen%d.mat',filespec)];
end
% Make sure file is present before calling load
file=fopen(filename);
% If not, make sure to try secondary directory.
if (file == -1 && (nargin < 3 || isempty(dir)))
useDir = CalDataFolder(1);
if (nargin < 1 || isempty(filespec))
filename = [useDir 'default.mat'];
elseif (ischar(filespec))
filename = [useDir filespec '.mat'];
else
filename = [useDir sprintf('screen%d.mat',filespec)];
end
file = fopen(filename);
end
% Now read the sucker if it is there.
if (file ~= -1)
fclose(file);
eval(['load ' QuoteString(filename)])
nCals = size(cals,2);
cal = cals{nCals};
if (nCals < nKeep)
return;
elseif (nKeep == 0)
cals = {};
elseif (nKeep == 1)
cals = {cals{nCals}};
else
cals = {cals{nCals-nKeep+1:nCals}};
end
% Save the flushed calibration file
eval(['save ' QuoteString(filename) ' cals']);
end
|