Skip to content

Commit 7b2b521

Browse files
committed
better path finders
1 parent f3b268a commit 7b2b521

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

wrappers/find_first_path.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function s = find_first_path(guesses)
2-
s = ...
3-
guesses{find(cellfun(@(guess) exist(guess,'file'),guesses),1,'first')};
4-
assert(~isempty(s),'Could not find path');
1+
function [s] = find_first_path(guesses)
2+
si = find(cellfun(@(guess) exist(guess,'file'),guesses),1,'first');
3+
assert(~isempty(si),'Could not find path');
4+
s = guesses{si};
55
end

wrappers/path_to_medit.m

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function s = path_to_medit()
1+
function [s] = path_to_medit()
22
% PATH_TO_MEDIT Return path to medit executable
33
%
44
% s = path_to_medit()
@@ -24,9 +24,7 @@
2424
guesses = { ...
2525
'/usr/local/bin/medit', ...
2626
'/opt/local/bin/medit'};
27-
s = ...
28-
guesses{find(cellfun(@(guess) exist(guess,'file'),guesses),1,'first')};
29-
assert(~isempty(s),'Could not find medit');
27+
s = find_first_path(guesses);
3028
end
3129
end
3230
end

wrappers/path_to_tetgen.m

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
'Could you put tetgen there and change this accordingly?' ...
1313
'Thanks, Alec']);
1414
s = 'c:/prg/lib/tetgen/Release/tetgen.exe';
15-
elseif ismac
16-
s = '/usr/local/bin/tetgen';
17-
elseif isunix
15+
elseif ismac || isunix
1816
% I guess this means linux
1917
[~,s] = system('which tetgen');
2018
s = strtrim(s);

0 commit comments

Comments
 (0)