File: IsMinimumOSXVersion.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (47 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download | duplicates (5)
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
function rc = IsMinimumOSXVersion(major, minor, point)
% rc = IsMinimumOSXVersion(major, minor, point);
%
% Checks if the script is running on a MacOS/X system with at least the
% requested (major,minor,point) version, e.g., to test for a MacOS/X system
% of 10.4.8 or later, do a IsMinimumOSXVersion(10,4,8);
%
% rc is 0 if the system is of a lower version, 1 if it satisfies this
% minimum version, 2 if the function doesn't know.

% History:
% 11/26/2007 Written (MK), based on code by Roger Woods (UCLA).
% 05/28/2012 Fixed this bullshit (MK).
% 11/01/2014 Convert to do without use of deprecated Gestalt() (MK).

if ~IsOSX
    rc = 0;
    return;
end

c = Screen('Computer');
sysversion = c.system;
sysnum = sscanf(sysversion, '%*s %*s %i.%i.%i');
[majorversion, minorversion, pointversion] = deal(sysnum(1), sysnum(2), sysnum(3));

% Preinit to 'No':
rc = 0;

if majorversion >= major
    if majorversion > major
        rc = 1;
        return;
    end

    if minorversion >= minor
        if minorversion > minor
            rc = 1;
            return;
        end

        if pointversion >= point
            rc = 1;
        end
    end
end

return;