blob: 6310dde50da54adfacf34ee5334b0c8e674c7ae9 (
plain)
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 [binary_location] = searchBinary(name, searchpath, err_fail)
% [binary_location] = searchBinary(name, searchpath<, err_fail>)
%
% Function to search for executable. If the executable isn't found
% in searchpath, look in environment search path.
%
% parameter:
% name: name of the binary to search
% searchpath: (list of) search paths
% err_fail: 0/1, throw an error if binary is not found (default is 1)
%
% Output:
% binary_location:
% if found in searchpath: full path of binary
% if found in environment search path: name of binary
% if not found: empty string
%
%
% openEMS matlab/octave interface
% -----------------------
% (C) 2013 Stefan Mahr <dac922@gmx.de>
if (nargin<3)
err_fail = 1;
end
if ischar(searchpath)
searchpath = {searchpath};
end
% append PATH search paths
searchpath = [searchpath regexp(getenv('PATH'), pathsep, 'split')];
% try all search paths
for n=1:numel(searchpath)
binary_location = [searchpath{n} name];
if exist(binary_location, 'file')
return
end
end
% binary not found
binary_location = '';
if (err_fail)
error('CSXCAD:binary_location', [name ' binary not found!']);
end
|