File: vrml_set_browser.m

package info (click to toggle)
octave-vrml 1.0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,404 kB
  • sloc: makefile: 37
file content (71 lines) | stat: -rw-r--r-- 2,656 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
## Copyright (C) 2012 Etienne Grossmann <etienne@egdn.net>
##
## This program 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.
##
## This program 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
## this program; if not, see <http://www.gnu.org/licenses/>.
##

## full_path = vrml_set_browser (proposed_browser) - Set or find a vrml browser
##
## If argument proposed_browser is passed and non-empty, then vmrl_set_browser()
## tries to determine whether proposed_browser is a valid program. If it is,
## then the global variable vrml_b_name is set to the full path, which is also
## returned. Otherwise, an error occurs.
##
## If argument proposed_browser is empty or missing, then vrml_set_browser()
## tries to determine whether either freewrl ( > 0.25) or whitedune (two vrml
## browsers) are available. If one is found, then the global variable
## vrml_b_name is set to the full path, which is also returned. Otherwise, an
## error occurs.
##
## WARNING: vrml_set_browser has only been tested under Linux. Please report
## successes / problems / patches on other systems.
##
## See also: vrml_browse(), FreeWRL homepage http://www.crc.ca/FreeWRL,
## whitedune homepage http://vrml.cip.ica.uni-stuttgart.de/dune,
## Castle Model Viewer homepage https://castle-engine.io/castle-model-viewer
##
function full_path = vrml_set_browser (proposed_browser_name)

global vrml_b_name = [];

full_path = vrml_b_name;

if nargin < 1 || isempty (proposed_browser_name)

  browser_list = {"castle-model-viewer", "freewrl", "whitedune"};

  for i = 1:numel(browser_list)

    ## TODO: Test this under windows
    [status, full_path] = system (sprintf ("which %s", browser_list{i}));
    if status != 1
      if full_path(length(full_path)) == "\n",
	full_path = full_path(1:end-1);
      end
      vrml_b_name = full_path;
      return;
    endif
  endfor

  error ("No VRML browser available");
endif

## TODO: Test this under windows
[status, full_path] = system (sprintf ("which %s", proposed_browser_name));
if status == 1
  error (sprintf ("VRML browser `%s' is not available", proposed_browser_name));
endif
if full_path(length(full_path)) == "\n",
  full_path = full_path(1:end-1);
end
vrml_b_name = full_path;