home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www;
-
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.URL;
- import java.net.URLConnection;
- import java.security.AccessController;
- import java.util.StringTokenizer;
- import sun.security.action.GetPropertyAction;
-
- class MimeLauncher extends Thread {
- // $FF: renamed from: uc java.net.URLConnection
- URLConnection field_0;
- // $FF: renamed from: m sun.net.www.MimeEntry
- MimeEntry field_1;
- String genericTempFileTemplate;
- // $FF: renamed from: is java.io.InputStream
- InputStream field_2;
- String execPath;
-
- MimeLauncher(MimeEntry var1, URLConnection var2, InputStream var3, String var4, String var5) throws ApplicationLaunchException {
- super(var5);
- this.field_1 = var1;
- this.field_0 = var2;
- this.field_2 = var3;
- this.genericTempFileTemplate = var4;
- String var6 = this.field_1.getLaunchString();
- if (!this.findExecutablePath(var6)) {
- int var8 = var6.indexOf(32);
- String var7;
- if (var8 != -1) {
- var7 = var6.substring(0, var8);
- } else {
- var7 = var6;
- }
-
- throw new ApplicationLaunchException(var7);
- }
- }
-
- protected String getTempFileName(URL var1, String var2) {
- int var4 = var2.lastIndexOf("%s");
- String var5 = var2.substring(0, var4);
- String var6 = "";
- if (var4 < var2.length() - 2) {
- var6 = var2.substring(var4 + 2);
- }
-
- long var7 = System.currentTimeMillis() / 1000L;
-
- int var13;
- for(var13 = 0; (var13 = var5.indexOf("%s")) >= 0; var5 = var5.substring(0, var13) + var7 + var5.substring(var13 + 2)) {
- }
-
- String var10 = var1.getFile();
- String var11 = "";
- int var12 = var10.lastIndexOf(46);
- if (var12 >= 0 && var12 > var10.lastIndexOf(47)) {
- var11 = var10.substring(var12);
- }
-
- var10 = "HJ" + var1.hashCode();
- String var3 = var5 + var10 + var7 + var11 + var6;
- return var3;
- }
-
- public void run() {
- try {
- String var1 = this.field_1.getTempFileTemplate();
- if (var1 == null) {
- var1 = this.genericTempFileTemplate;
- }
-
- var1 = this.getTempFileName(this.field_0.getURL(), var1);
-
- try {
- FileOutputStream var2 = new FileOutputStream(var1);
- byte[] var3 = new byte[2048];
- int var4 = 0;
-
- try {
- while((var4 = this.field_2.read(var3)) >= 0) {
- ((OutputStream)var2).write(var3, 0, var4);
- }
- } catch (IOException var12) {
- } finally {
- ((OutputStream)var2).close();
- this.field_2.close();
- }
- } catch (IOException var14) {
- }
-
- int var17 = 0;
-
- String var20;
- for(var20 = this.execPath; (var17 = var20.indexOf("%t")) >= 0; var20 = var20.substring(0, var17) + this.field_0.getContentType() + var20.substring(var17 + 2)) {
- }
-
- boolean var22;
- for(var22 = false; (var17 = var20.indexOf("%s")) >= 0; var22 = true) {
- var20 = var20.substring(0, var17) + var1 + var20.substring(var17 + 2);
- }
-
- if (!var22) {
- var20 = var20 + " <" + var1;
- }
-
- Runtime.getRuntime().exec(var20);
- } catch (IOException var15) {
- }
-
- }
-
- private boolean findExecutablePath(String var1) {
- if (var1 != null && var1.length() != 0) {
- int var3 = var1.indexOf(32);
- String var2;
- if (var3 != -1) {
- var2 = var1.substring(0, var3);
- } else {
- var2 = var1;
- }
-
- File var4 = new File(var2);
- if (var4.isFile()) {
- this.execPath = var1;
- return true;
- } else {
- String var5 = (String)AccessController.doPrivileged(new GetPropertyAction("exec.path"));
- if (var5 == null) {
- return false;
- } else {
- StringTokenizer var6 = new StringTokenizer(var5, "|");
-
- while(var6.hasMoreElements()) {
- String var7 = (String)var6.nextElement();
- String var8 = var7 + File.separator + var2;
- var4 = new File(var8);
- if (var4.isFile()) {
- this.execPath = var7 + File.separator + var1;
- return true;
- }
- }
-
- return false;
- }
- }
- } else {
- return false;
- }
- }
- }
-