Refactored some things to allow us to use them in externally.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Application.java,v 1.27 2004/08/03 00:10:34 mdb Exp $
|
||||
// $Id: Application.java,v 1.28 2004/08/03 03:29:58 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.data;
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.apache.commons.io.CopyUtils;
|
||||
|
||||
import com.threerings.getdown.Log;
|
||||
import com.threerings.getdown.util.ConfigUtil;
|
||||
import com.threerings.getdown.util.LaunchUtil;
|
||||
import com.threerings.getdown.util.MetaProgressObserver;
|
||||
import com.threerings.getdown.util.ProgressObserver;
|
||||
|
||||
@@ -379,20 +380,7 @@ public class Application
|
||||
int idx = 0;
|
||||
|
||||
// reconstruct the path to the JVM
|
||||
String apbase = System.getProperty("java.home") +
|
||||
File.separator + "bin" + File.separator;
|
||||
String apath = apbase + "java";
|
||||
if (!new File(apath).exists()) {
|
||||
apath = apbase + "javaw.exe";
|
||||
if (!new File(apath).exists()) {
|
||||
apath = apbase + "java.exe";
|
||||
if (!new File(apath).exists()) {
|
||||
Log.warning("Unable to find java! [jhome=" + apbase + "].");
|
||||
apath = apbase + "java";
|
||||
}
|
||||
}
|
||||
}
|
||||
args[idx++] = apath;
|
||||
args[idx++] = LaunchUtil.getJVMPath();
|
||||
|
||||
// add the classpath arguments
|
||||
args[idx++] = "-classpath";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Getdown.java,v 1.32 2004/08/02 20:07:33 mdb Exp $
|
||||
// $Id: Getdown.java,v 1.33 2004/08/03 03:29:58 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.launcher;
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.threerings.getdown.data.Application;
|
||||
import com.threerings.getdown.data.Resource;
|
||||
import com.threerings.getdown.tools.Patcher;
|
||||
import com.threerings.getdown.util.ConfigUtil;
|
||||
import com.threerings.getdown.util.LaunchUtil;
|
||||
import com.threerings.getdown.util.ProgressObserver;
|
||||
|
||||
/**
|
||||
@@ -462,19 +463,17 @@ public class Getdown extends Thread
|
||||
try {
|
||||
Process proc = _app.createProcess();
|
||||
|
||||
// on Windows 98 we need to stick around and read the output
|
||||
// of stdout lest the process fills its output buffer and
|
||||
// chokes, yay!
|
||||
String osname = System.getProperty("os.name").toLowerCase();
|
||||
if (osname.indexOf("windows 98") != -1 ||
|
||||
osname.indexOf("windows me") != -1) {
|
||||
// on Windows 98 and ME we need to stick around and read the
|
||||
// output of stderr lest the process fill its output buffer
|
||||
// and choke, yay!
|
||||
if (LaunchUtil.mustMonitorChildren()) {
|
||||
// close our window if it's around
|
||||
if (_frame != null) {
|
||||
_frame.dispose();
|
||||
_status = null;
|
||||
_frame = null;
|
||||
}
|
||||
Log.info("Sticking around to read stderr on " + osname + "...");
|
||||
Log.info("Sticking around to read stderr...");
|
||||
InputStream stderr = proc.getErrorStream();
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(stderr));
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// $Id: LaunchUtil.java,v 1.1 2004/08/03 03:29:58 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.threerings.getdown.Log;
|
||||
|
||||
/**
|
||||
* Useful routines for launching Java applications from within other Java
|
||||
* applications.
|
||||
*/
|
||||
public class LaunchUtil
|
||||
{
|
||||
/**
|
||||
* Reconstructs the path to the JVM used to launch this process.
|
||||
*/
|
||||
public static String getJVMPath ()
|
||||
{
|
||||
String apbase = System.getProperty("java.home") +
|
||||
File.separator + "bin" + File.separator;
|
||||
String apath = apbase + "java";
|
||||
if (!new File(apath).exists()) {
|
||||
apath = apbase + "javaw.exe";
|
||||
if (!new File(apath).exists()) {
|
||||
apath = apbase + "java.exe";
|
||||
if (!new File(apath).exists()) {
|
||||
Log.warning("Unable to find java! [jhome=" + apbase + "].");
|
||||
apath = apbase + "java";
|
||||
}
|
||||
}
|
||||
}
|
||||
return apath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if, on this operating system, we have to stick around
|
||||
* and read the stderr from our children processes to prevent them
|
||||
* from filling their output buffers and hanging.
|
||||
*/
|
||||
public static boolean mustMonitorChildren ()
|
||||
{
|
||||
String osname = System.getProperty("os.name").toLowerCase();
|
||||
return (osname.indexOf("windows 98") != -1 ||
|
||||
osname.indexOf("windows me") != -1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user