Skip to content

Commit

Permalink
Merge pull request #777 from robertoostenveld/issue727
Browse files Browse the repository at this point in the history
FIX #727 - add isfolder to path for octave, implemented octaveversion…
  • Loading branch information
robertoostenveld committed Aug 20, 2018
2 parents ba824fd + a065b2e commit a446c08
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 27 deletions.
10 changes: 9 additions & 1 deletion bin/synchronize-private.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ ARRAY+=(test/private/icosahedron642.m)
sync ${ARRAY[*]}

################################################################################
# ignnorefields.m
# ignorefields.m

ARRAY=()
ARRAY+=(private/ignorefields.m)
Expand Down Expand Up @@ -1333,6 +1333,14 @@ ARRAY+=(test/private/isalmostequal.m)
ARRAY+=(private/isalmostequal.m)
sync ${ARRAY[*]}

################################################################################
# isfolder.m

ARRAY=()
ARRAY+=(compat/matlablt2017b/isfolder.m)
ARRAY+=(compat/octave/isfolder.m)
sync ${ARRAY[*]}

################################################################################
# isrealmat.m

Expand Down
10 changes: 10 additions & 0 deletions compat/octave/isfolder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function tf = isfolder(dirpath)

%ISFOLDER Determine if the input path points to a folder
% TF = ISFOLDER(PATH) returns true if PATH points to a folder and false otherwise.
%
% This is a compatibility function that should only be added to the path on
% MATLAB versions prior to 2017b.

tf = exist(dirpath,'dir') == 7;

2 changes: 2 additions & 0 deletions ft_defaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
if ft_platform_supports('matlabversion', -inf, '2019b'), ft_hastoolbox('compat/matlablt2020a', 3, 1); end
if ft_platform_supports('matlabversion', -inf, '2020a'), ft_hastoolbox('compat/matlablt2020b', 3, 1); end
if ft_platform_supports('matlabversion', -inf, '2020b'), ft_hastoolbox('compat/matlablt2021a', 3, 1); end
% this deals with compatibility with all OCTAVE versions
if ft_platform_supports('octaveversion', -inf, +inf), ft_hastoolbox('compat/octave', 3, 1); end
end

try
Expand Down
78 changes: 52 additions & 26 deletions utilities/ft_platform_supports.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,38 @@
%
% See also FT_VERSION, VERSION, VER, VERLESSTHAN

% Copyright (C) 2006, Robert Oostenveld
% Copyright (C) 2010, Eelke Spaak
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
% FieldTrip is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% FieldTrip is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id$


if ~ischar(what)
error('first argument must be a string');
end

switch what
case 'matlabversion'
tf = is_matlab() && matlabversion(varargin{:});

case 'octaveversion'
tf = is_octave() && octaveversion(varargin{:});

case 'exists-in-private-directory'
tf = is_matlab();
Expand Down Expand Up @@ -206,11 +231,31 @@

end % function


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SUBFUNCTION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [inInterval] = matlabversion(min, max)
function [inInterval] = octaveversion(min, max)
% the version does not change, making it persistent speeds up the subsequent calls
persistent curVer

if nargin<2
max = min;
end

if isempty(curVer)
curVer = OCTAVE_VERSION;
end

% perform comparison with respect to version number
[major, minor] = parseMatlabVersion(curVer);
[minMajor, minMinor] = parseMatlabVersion(min);
[maxMajor, maxMinor] = parseMatlabVersion(max);

inInterval = orderedComparison(minMajor, minMinor, maxMajor, maxMinor, major, minor);

end % function


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MATLABVERSION checks if the current MATLAB version is within the interval
% specified by min and max.
%
Expand All @@ -229,27 +274,8 @@
% etc.
%
% See also VERSION, VER, VERLESSTHAN

% Copyright (C) 2006, Robert Oostenveld
% Copyright (C) 2010, Eelke Spaak
%
% This file is part of FieldTrip, see http://www.fieldtriptoolbox.org
% for the documentation and details.
%
% FieldTrip is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% FieldTrip is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id$
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [inInterval] = matlabversion(min, max)

% the version does not change, making it persistent speeds up the subsequent calls
persistent curVer
Expand Down Expand Up @@ -311,8 +337,8 @@
minor = int8((ver - floor(ver)) * 10);
else % ver is string (e.g. '7.10'), parse accordingly
[major, rest] = strtok(ver, '.');
major = str2num(major);
minor = str2num(strtok(rest, '.'));
major = str2double(major);
minor = str2double(strtok(rest, '.'));
end
end % function

Expand Down

0 comments on commit a446c08

Please sign in to comment.