File: mcpath.m

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (56 lines) | stat: -rw-r--r-- 1,787 bytes parent folder | download
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
48
49
50
51
52
53
54
55
56
function binname = mcpath(fname, ext)
%
% binname=mcpath(fname)
%
% get full executable path by prepending a command directory path
% parameters:
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
%    fname: input, a file name string
%
% output:
%    binname: output, full file name located in the bin directory
%
%    if global variable ISO2MESH_BIN is set in 'base', it will
%    use [ISO2MESH_BIN filesep cmdname] as the command full path,
%    otherwise, let matlab pass the cmdname to the shell, which
%    will search command in the directories listed in system
%    $PATH variable.
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

p = getvarfrom({'caller', 'base'}, 'ISO2MESH_BIN');
binname = [];
if (isempty(p))
    % the bin folder under iso2mesh is searched first
    tempname = [fileparts(which(mfilename)) filesep 'bin' filesep fname];
    if (exist([fileparts(which(mfilename)) filesep 'bin']) == 7)
        if (nargin >= 2 && ~isempty(ext))
            if (exist([tempname ext], 'file'))
                binname = [tempname ext];
            else
                binname = fname; % use binary without suffix on system PATH
            end
        else
            binname = tempname;
        end
    else
        binname = fname;
    end
else
    binname = [p filesep fname];
end
% on 64bit windows machine, try 'exename_x86-64.exe' first
if (ispc && ~isempty(regexp(computer, '64', 'once')) && isempty(regexp(fname, '_x86-64$', 'once')))
    w64bin = regexprep(binname, '(\.[eE][xX][eE])*$', '_x86-64.exe', 'emptymatch');
    if (exist(w64bin, 'file'))
        binname = w64bin;
    end
end
% if no such executable exist in iso2mesh/bin, find it in PATH env variable
if (nargin >= 2 && ~exist(binname, 'file'))
    binname = fname;
end