📄 ostype.m
字号:
function otype = ostype(tag)
% ostype - returns information about the currently used OS
%
% FORMAT: otype = ostype([tag])
%
% Input fields:
%
% tag optionally requesting a subfield of the struct
%
% Output fields:
%
% otype 1x1 struct with fields
% .computer copy of computer()
% .filesep copy of filesep()
% .ispc copy of ispc()
% .machine either 'MAC', 'UNIX', or 'WIN'
%
% See also COMPUTER, FILESEP, ISPC
% Version: v0.5c
% Build: 6120415
% Date: Dec-04 2006, 3:15 PM CET
% Author: Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools
% declare and (if needed) init persitently stored variable
persistent bvqx_osinfo;
if isempty(bvqx_osinfo) || ...
~isstruct(bvqx_osinfo) || ...
~bvqx_osinfo.is_initialized
% initialize persistent variable
bvqx_osinfo = struct;
bvqx_osinfo.is_initialized = false;
% get values
bvqx_osinfo.computer = upper(computer);
bvqx_osinfo.filesep = filesep;
bvqx_osinfo.ispc = ispc;
if ~isempty(strfind(bvqx_osinfo.computer, 'WIN'))
bvqx_osinfo.machine = 'WIN';
elseif ~isempty(strfind(bvqx_osinfo.computer, 'MAC'))
bvqx_osinfo.machine = 'MAC';
else
bvqx_osinfo.machine = 'UNIX';
end
% sanity checks
if ...
(strcmp(bvqx_osinfo.machine, 'UNIX') && filesep ~= '/') || ...
(strcmp(bvqx_osinfo.machine, 'WIN') && filesep ~= '\')
error( ...
'BVQXtools:InternalError', ...
'Initialization failed. Bad filesep for machine type %s', ...
bvqx_osinfo.machine ...
);
end
% set initialized to true
bvqx_osinfo.is_initialized = true;
end
% argument check
if nargin < 1 || ...
~ischar(tag) || ...
isempty(tag)
tag = 'full';
else
tag = lower(tag(:));
end
switch (tag)
case {'filesep'}
otype = bvqx_osinfo.filesep;
case {'machine'}
otype = bvqx_osinfo.machine;
otherwise
otype = bvqx_osinfo;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -