KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ghostscript.m
Go to the documentation of this file.
1 
2 
3 /* (Autoinserted by mtoc++)
4  * This source code has been filtered by the mtoc++ executable,
5  * which generates code that can be processed by the doxygen documentation tool.
6  *
7  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
8  * Except for the comments, the function bodies of your M-file functions are untouched.
9  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
10  * attached source files that are highly readable by humans.
11  *
12  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
13  * the correct locations in the source code browser.
14  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
15  */
16 
17 function varargout = ghostscript(cmd) {
18 shell_cmd = ;
19 if isunix
20  shell_cmd = " export LD_LIBRARY_PATH=''; "; /* Avoids an error on Linux with GS 9.07 */
21 
22 end
23 /* Call ghostscript */
24 [varargout[1:nargout]] = system(sprintf(" %s'%s' %s ", shell_cmd, gs_path, cmd));
25 return
26 
27 }
38 function path_ = ghostscript>gs_path() {
39 path_ = user_string(" ghostscript ");
40 /* Check the path works */
41 if check_gs_path(path_)
42  return
43 end
44 /* Check whether the binary is on the path */
45 if ispc
46  bin = [" gswin32c.exe ", " gswin64c.exe ", " gs "];
47 else
48  bin = [" gs "];
49 end
50 for a = 1:numel(bin)
51  path_ = bin[a];
52  if check_store_gs_path(path_)
53  return
54  end
55 end
56 /* Search the obvious places */
57 if ispc
58  default_location = " C:\Program Files\gs\ ";
59  dir_list = dir(default_location);
60  if isempty(dir_list)
61  default_location = " C:\Program Files (x86)\gs\ "; /* Possible location on 64-bit systems */
62 
63  dir_list = dir(default_location);
64  end
65  executable = [" \bin\gswin32c.exe ", " \bin\gswin64c.exe "];
66  ver_num = 0;
67  /* If there are multiple versions, use the newest */
68  for a = 1:numel(dir_list)
69  ver_num2 = sscanf(dir_list(a).name, " gs%g ");
70  if ~isempty(ver_num2) && ver_num2 > ver_num
71  for b = 1:numel(executable)
72  path2 = [default_location dir_list(a).name executable[b]];
73  if exist(path2, " file ") == 2
74  path_ = path2;
75  ver_num = ver_num2;
76  end
77  end
78  end
79  end
80  if check_store_gs_path(path_)
81  return
82  end
83 else
84  bin = [" /usr/bin/gs ", " /usr/local/bin/gs "];
85  for a = 1:numel(bin)
86  path_ = bin[a];
87  if check_store_gs_path(path_)
88  return
89  end
90  end
91 end
92 /* Ask the user to enter the path */
93 while 1
94  if strncmp(computer, " MAC ", 3) /* Is a Mac
95  * Give separate warning as the uigetdir dialogue box doesn't have a
96  * title */
97 
98  uiwait(warndlg(" Ghostscript not found. Please locate the program. "))
99  end
100  base = uigetdir(" / ", " Ghostcript not found. Please locate the program. ");
101  if isequal(base, 0)
102  /* User hit cancel or closed window */
103  break;
104  end
105  base = [base filesep];
106  bin_dir = [, [" bin " filesep], [" lib " filesep]];
107  for a = 1:numel(bin_dir)
108  for b = 1:numel(bin)
109  path_ = [base bin_dir[a] bin[b]];
110  if exist(path_, " file ") == 2
111  if check_store_gs_path(path_)
112  return
113  end
114  end
115  end
116  end
117 end
118 error(" Ghostscript not found. Have you installed it from www.ghostscript.com? ");
119 
120 }
121 
122 function good = ghostscript>check_store_gs_path(path_) {
123 good = check_gs_path(path_);
124 if ~good
125  return
126 end
127 /* Update the current default path to the path found */
128 if ~user_string(" ghostscript ", path_)
129  warning(" Path to ghostscript installation could not be saved. Enter it manually in ghostscript.txt. ");
130  return
131 end
132 return
133 
134 }
135 
136 function good = ghostscript>check_gs_path(path_) {
137 [good, message] = system(sprintf(" '%s' -h ", path_));
138 good = good == 0;
139 return
140 }
141 
function string = user_string(string_name, string)
Definition: user_string.m:17
function good = ghostscript>check_gs_path(path_)
Definition: ghostscript.m:136
function varargout = ghostscript(cmd)
Initialize any required system calls before calling ghostscript.
Definition: ghostscript.m:17
function good = ghostscript>check_store_gs_path(path_)
Definition: ghostscript.m:122
function path_ = ghostscript>gs_path()
Definition: ghostscript.m:38
A variable number of output arguments.