10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.net.www;
27 import java.net.URL;
28 import java.io.*;
29 import java.util.StringTokenizer;
30
31 class MimeLauncher extends Thread {
32 java.net.URLConnection uc;
33 MimeEntry m;
34 String genericTempFileTemplate;
35 InputStream is;
36 String execPath;
37
38 MimeLauncher (MimeEntry M, java.net.URLConnection uc,
39 InputStream is, String tempFileTemplate, String threadName) throws ApplicationLaunchException {
40 super(null, null, threadName, 0, false);
41 m = M;
42 this.uc = uc;
43 this.is = is;
44 genericTempFileTemplate = tempFileTemplate;
45
46 /* get the application to launch */
47 String launchString = m.getLaunchString();
48
49 /* get a valid path to launch application - sets
165 return false;
166 }
167
168 String command;
169 int index = str.indexOf(' ');
170 if (index != -1) {
171 command = str.substring(0, index);
172 }
173 else {
174 command = str;
175 }
176
177 File f = new File(command);
178 if (f.isFile()) {
179 // Already executable as it is
180 execPath = str;
181 return true;
182 }
183
184 String execPathList;
185 execPathList = java.security.AccessController.doPrivileged(
186 new sun.security.action.GetPropertyAction("exec.path"));
187 if (execPathList == null) {
188 // exec.path property not set
189 return false;
190 }
191
192 StringTokenizer iter = new StringTokenizer(execPathList, "|");
193 while (iter.hasMoreElements()) {
194 String prefix = (String)iter.nextElement();
195 String fullCmd = prefix + File.separator + command;
196 f = new File(fullCmd);
197 if (f.isFile()) {
198 execPath = prefix + File.separator + str;
199 return true;
200 }
201 }
202
203 return false; // application not found in exec.path
204 }
205 }
|
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.net.www;
27 import java.net.URL;
28 import java.io.*;
29 import java.util.StringTokenizer;
30 import sun.security.action.GetPropertyAction;
31
32 class MimeLauncher extends Thread {
33 java.net.URLConnection uc;
34 MimeEntry m;
35 String genericTempFileTemplate;
36 InputStream is;
37 String execPath;
38
39 MimeLauncher (MimeEntry M, java.net.URLConnection uc,
40 InputStream is, String tempFileTemplate, String threadName) throws ApplicationLaunchException {
41 super(null, null, threadName, 0, false);
42 m = M;
43 this.uc = uc;
44 this.is = is;
45 genericTempFileTemplate = tempFileTemplate;
46
47 /* get the application to launch */
48 String launchString = m.getLaunchString();
49
50 /* get a valid path to launch application - sets
166 return false;
167 }
168
169 String command;
170 int index = str.indexOf(' ');
171 if (index != -1) {
172 command = str.substring(0, index);
173 }
174 else {
175 command = str;
176 }
177
178 File f = new File(command);
179 if (f.isFile()) {
180 // Already executable as it is
181 execPath = str;
182 return true;
183 }
184
185 String execPathList;
186 execPathList = GetPropertyAction.getProperty("exec.path");
187 if (execPathList == null) {
188 // exec.path property not set
189 return false;
190 }
191
192 StringTokenizer iter = new StringTokenizer(execPathList, "|");
193 while (iter.hasMoreElements()) {
194 String prefix = (String)iter.nextElement();
195 String fullCmd = prefix + File.separator + command;
196 f = new File(fullCmd);
197 if (f.isFile()) {
198 execPath = prefix + File.separator + str;
199 return true;
200 }
201 }
202
203 return false; // application not found in exec.path
204 }
205 }
|